Interview
05 OctoberSeparate odd and even numbers in an array
Problem : Given an array of integers, you need to segregate odd and even numbers in an array. Please note : Order of elements can be changed. For example: arr[] = {12, 17, 70, 15, 22, 65, 21, 90} Array after separating odd and even numbers : {12, 90, 70, 22, 15, 65, 21, 17} […]
05 OctoberFind leaders in an array
Problem: We need to print all the leaders present in the array. Element is the leader if it is greater than right side of elements. For example: arr[]={14, 12, 70, 15, 99, 65, 21, 90} Here 99 and 90 are leader elements Solution: Solution 1: Use two loops. Outer loop to iterate over array elements […]
03 OctoberStock Buy Sell to Maximize Profit
If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. [toc] Given an array of integers representing stock price on a single day, find max profit that can be earned by 1 transaction. So you need to find a pair (buyDay,sellDay) where buyDay < = sellDay and […]
03 OctoberSearch in a row wise and column wise sorted matrix
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Problem : Given row wise and column wise sorted matrix ,we need to search element with minimum […]
03 OctoberFind all pairs of elements from an array whose sum is equal to given number
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Problem : Given a array,we need to find all pairs whose sum is equal to number X. For example: array[]={ -40, -5, 1, 3, 6, 7, 8, 20 }; Pair of elements whose sum is equal […]
01 OctoberGiven a sorted array and a number x, find the pair in array whose sum is closest to x
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Problem : Given a sorted array,we need to find a pair whose sum is closed to number X in Array. For example: array[]={-40,-5,1,3,6,7,8,20}; The pair whose sum is closest to 5 : 1 and 3 Solution […]
01 OctoberFind a Pair Whose Sum is Closest to zero in Array
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Problem : Given array of +ve and -ve integers ,we need to find a pair whose sum is closed to Zero in Array. For example: array[]={1,3,-5,7,8,20,-40,6}; The pair whose sum is closest to zero : -5 […]
29 Septemberfind transpose of a matrix 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 find transpose of matrix in java. Transpose of matrix? A matrix which is created by converting all the rows of a given matrix into columns and vice-versa. Below […]
28 SeptemberMinimum Number of Platforms Required for A Railway Station
If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. 1. Introduction to Problem You are given arrival and departure time of trains reaching to a particular station. You need to find minimum number of platforms required to accommodate the trains at any point of time. […]