Target Sum – Leetcode

Problem You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and – as its new symbol. Find out how many ways to assign symbols to make sum of integers equal to … [Read more…]

Largest Palindrome Product – Leetcode

Problem Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindrome mod 1337. Example: Input: 3  ,  Output: 987 Explanation: 99 x 91 = 9009, 9009 % 1337 = 987 Note:  The range of n is [1,8]. Solution And if … [Read more…]

why string is immutable in java

What is immutable String? String class in java cannot be modified once created.  So let us create two string objects below So once we created the above two strings, the values of these two strings cannot be modified as String class doesn’t provide any method that can allow to modify the value of a String. … [Read more…]

calculate the Hamming distance for two given integers

Problem The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Example: Input: x = 8, y = 1 Output: 2 Explanation: number    bits 8 1 0 0 0 1 0 0 0 1 Solution With … [Read more…]

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize= ; support was removed in 8.0

Error Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=m; support was removed in 8.0 Since When After migrating to Java 8 Solution Remove  MaxPermSize  as this is not needed anymore. You should see if you want to define MaxMetaspaceSize -XX:MaxMetaspaceSize=<metaspace size>[g|m|k] By default Metaspace in Java VM 8 is not limited, but for system stability it … [Read more…]

Binary Tree Paths – Given a binary tree, return all root-to-leaf paths.

Problem. Given a binary tree, return all root-to-leaf paths. Given Tree   Print all the root-to-leaf path 1->2->3 1->2->5 1->3 Solution TreeNode Data Structure Binary Tree Solution OutPut

Redirect root domain to subdmain in blogger

If you have already followed all the instructions and pointed your subdomain to blogger and have your subdomain working fine.But now you want your root domain not to show a “page not found”. You can redirect your root domain to the subdomain pointing to blogger.  It is very easy. 1. Go to settings > Basic … [Read more…]

[WARNING] schema_reference: Failed to read schema document ‘?xsd=1’, because ‘http’ access is not allowed due to restriction set by the accessExternalSchema property , java 8

We are using web services in our project. And once we moved from Java 1.7 to Java 1.8, we started to get the error while building the web service client. Easy Solution And the solution to this issue was to create a a file jaxp.properties in the /pathto/jdk1.8.0_111/jre/lib folder. And the contents of the file … [Read more…]

Web Crawler using jsoup

In this tutorial we will be looking at creating a simple web crawler using jsoup. 1. Declare Maven Dependency In case you don’t know how to create a project, you can read about it create new maven project. 2.  Choose a wepage to crawl In this tutorial we will choose Hollinger NBA Player Statistics. So we … [Read more…]

Create your first Maven Project with eclipse

In this tutorial we are going to see how to create a simple maven project in eclipse. 1. Download Maven integration plugin Download the maven integration plugin from eclipse marketplace. The plugin makes it easier to create and work with maven projects in eclipse. In the below picture, you can selected the one which shows … [Read more…]