Algorithm Interview
- 10 September
Implement Stack using two Queues in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. In this program, we will see how to implement stack using Linked List in java. Stack is abstract data type which demonstrates Last in first out (LIFO) behavior. We will implement same behavior using two queue. There […]
- 15 July
Find all Permutations of a String in java
In this post, we will see how to find all permutations of String in java. We will use a very simple approach to do it. Take out first character of String and insert into different places of permutations of remaining String recursively. Lets say you have String as ABC. So we take out A from […]
- 17 May
How to check if one String is rotation of another String in java
In this post, we will see how to check if one String is rotation of another or not. For example: [crayon-672a130aa2c6c983267641/] Approach: Lets say you need to check whether str1 and str2 is rotation of one another or not. Create a new String with str3= str1 + str1 Check if str3 contains str2 or not. […]
- 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 […]
- 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. […]