Algorithm Interview
- 08 August
Fibonacci series program in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. Fibonacci series is numerical series in which next number is sum of previous two numbers. For example : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. There are two ways to print Fibonacci […]
- 06 August
Find first non repeated character in a String
One of the interview question is “How will you find first non repeating character in String.” For example: If input string is “analogy”, then program should return ‘n’ If input string is “easiest”, then program should return ‘a’ First approach: We will use [LinkedHashMap](https://java2blog.com/linkedhashmap-in-java-with-example/ “LinkedHashMap”) to find first non repeating character in String. Algorithm: Get […]
- 01 August
Java program to reverse a String
In this post, we will see java program to reverse a String. There are many ways to do reverse a String in java, some of them are: Using for loop Declare empty String reverse. This will contain our final reversed string. Iterate over array using for loop from last index to 0th index Add character […]
- 08 July
Binary search in java
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. In this post, we will see how to perform binary search in java using divide and conquer method.When you want to find a value in sorted array, we use binary search and we will also see […]
- 04 August
print all paths from root to leaf in a binary tree in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. This is 9th part of java binary tree tutorial. In this post, we will see about program to print all paths from root to leaf in a binary tree in java. Below diagram will show all paths […]
- 04 August
Spiral/Zigzag level order traversal of binary tree in java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. This is 6th part of java binary tree tutorial. In this post, we will see about Spiral/Zigzag Level Order binary tree traversal in java. Spiral/Zigzag Level Order traversal: Spiral/Zigzag Level order traversal of below tree will be: […]
- 20 July
How to Print Leaf Nodes of a Binary Tree in Java
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. 1. Introduction In this post, we will see how to count leaf nodes in a binary tree in Java. Understanding how to count leaf nodes is useful for various applications in computer science, such as calculating the […]
- 20 July
How to Count Leaf Nodes in a Binary Tree in Java
If you want to practice data structure and algorithm programs, you can go through 100+ Java coding interview questions. 1. Introduction In this post, we will see how to count leaf nodes in a binary tree in Java. Understanding how to count leaf nodes is useful for various applications in computer science, such as calculating […]
- 15 July
Binary Tree PreOrder Traversal in Java
If you want to practice data structure and algorithm programs, you can go through top 100+ data structure and algorithm interview questions. 1. Introduction In this article, we will explore the concept of InOrder traversal in binary trees, focusing on its implementation in Java. In computer science, a binary tree is a foundational data structure, and […]