Interview
- 10 May
How to check if two Strings are Anagrams in Java
In this post, we will see how to check if two Strings are Anagrams in java. Anagrams mean if two Strings have the same characters but in a different order. For example: Angel and Angle are anagrams There are many ways to check if Strings are anagrams in java. Some of them are: Using String […]
- 08 May
Java Program to find duplicate Characters in a String
In this post, we will see how to find duplicate Characters in a String. Approach: Create a HashMap and character of String will be inserted as key and its count as value. If Hashamap already contains char,increase its count by 1, else put char in HashMap If value of Char is more than 1, that means it […]
- 07 May
Why String is immutable in java
String class is immutable in java. If you take dictionary meaning of immutable, it means unable to be changed or unchanging over time, so String is unchangeable or unmodifiable in java. Let’s understand with example. [crayon-6768695b63395494930088/] As you can see, value of str1 did not change. It created another String object with value “Hellojava2blog” but […]
- 29 April
HashMap in java
HashMap is hash table based implementation of Map interface. It stores entry in key-value pairs. It maps keys to values. It is one of the most used Collection. Java HashMap HashMap implements Map an interface that maps a key to value. It is not synchronized and is not thread-safe. Duplicate keys are not allowed One […]
- 29 April
TreeMap in java with examples
TreeMap class implements Map similar to HashMap. Some important points about TreeMap: TreeMap implements Map interface and extends HashMap class. TreeMap is implemented using Red black tree based NavigableMap. TreeMap is ordered collection and store its elements in natural ordering of keys. Key which you would like to put in TreeMap must implement Comaparable interface or you can […]
- 15 April
Binary search tree in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. Binary search tree is a special type of binary tree which have following properties. Nodes which are smaller than root will be in left subtree. Nodes which are greater than root will be right subtree. It should […]
- 15 April
Find minimum and maximum elements in binary search tree in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. In this post, we will see how to find minimum and maximum elements in binary search tree. Finding minimum element: Minimum element is nothing but leftmost node in binary search tree, so traverse left until you get […]
- 14 April
Lowest Common Ancestor (LCA) of binary search tree in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. In this post, we will see how to find lowest common ancestor(LCA) of two nodes in binary search tree. We have already seen how to find LCA in binary tree. It is much simple than that. Lets […]
- 14 April
Lowest Common Ancestor (LCA) of binary tree in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. In this post, we will see how to find lowest common ancestor(LCA) of two nodes in binary tree. Lets understand with example. As you can see here, LCA is nothing but lowest common parent of two nodes. […]