Interview
- 22 October
Sliding Window Maximum in java
In this post, we will see about Sliding Window Maximum in java Problem Given an Array of integers and an Integer k, Find the maximum element of from all the contiguous subarrays of size K. For eg : Input : int[] arr = {2,6,-1,2,4,1,-6,5} int k = 3 output : 6,6,4,4,4,5 for every subarray of […]
- 22 October
Why wait(), notify() And notifyAll() methods are in Object Class
In this post, we will see why wait(), notify() And notifyAll() methods are in Object Class And Not in Thread Class. This is one of the most asked java multithreading interview questions. You might know that wait(), notify() And notifyAll() Methods are in Object class and do you know the reason for the same? Let’s […]
- 21 October
Difference between equals() and == in java
In this post, we will see about the difference between equals and == in java. This is most asked java interview question for fresher or 2-year experienced java developer and it might be confusing sometimes. Let’s try to understand each quickly. Equality operator “==” Equality operator can be used to compare primitives but when you […]
- 14 October
Find peak element in the array
If you want to practice data structure and algorithm programs, you can go through 100+ data structure and algorithm programs. In this post, we will see how to find peak element in the array. Problem Given an array of integers. find the peak element in the array. Peak Element is the element of the array […]
- 27 September
Print maximum occurring character in a String
In this post, we will see how to print the maximum occurring character in a String. Problem Print maximum occurring character in a String For example: String 1: java2blog tutorial Character: a has occurred maximum times in String: 3 ———————- String 2: This is test message Character: s has occurred maximum times in String: 5 […]
- 18 August
Print all paths from top left to bottom right of MxN matrix
In this post, we will see how to print all paths from top left to bottom right of MxN matrix. Problem We need to print all paths from top left to bottom right of MxN matrix. You can either move down or right. Solution You can solve this problem using recursion. Recursion We will pass row […]
- 18 August
Print Numbers from 1 to N without using loop
In this post, we will see how to print numbers from 1 to N without using loop. Problem Print number from 1 to N without using any loop. N=10 Output: 1 2 3 4 5 6 7 8 9 10 Using Recursion We can use tail recursion to solve this problem. Base case When n […]
- 16 August
Find all subsets of set (power set) in java
In this post, we will see how to find all subsets of set or power set in java. Problem Given a set of distinct integers, arr, return all possible subsets (the power set). For example: Input: nums = [1,2,3] Output: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ] We will use two approaches here. Using […]
- 13 August
Permutations of array in java
In this post, we will see how to find all permutations of the array in java. Problem 1 Given array of distinct integers, print all permutations of the array. For example: array : [10, 20, 30] Permuations are : [10, 20, 30] [10, 30, 20] [20, 10, 30] [20, 30, 10] [30, 10, 20] [30, 20, […]