• 29 September

    find 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 […]

  • 06 October

    Maximum difference between two elements such that larger element appears after the smaller number

    If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. Given array of integers, find Maximum difference between two elements such that larger element appears after the smaller number For example: [crayon-60ce1471e83c5329138323/] Algorithm: Lets say we have array arr[] of stock prices. We will track two variable :minElementTillNow and maxDifference. minElementTillNow will be […]

  • 03 October

    Stock Buy Sell to Maximize Profit

    If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. 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 it […]

  • 28 September

    Minimum 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. 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. For example: [crayon-60ce1471e8ea5724333523/] […]

  • 02 February

    Rotate an array by K positions

    In this tutorial, we will see how to rotate an array be K positions. Problem: N=6 and k=2 If Arr[] = {1, 2, 3, 4, 5, 6} and k=2 then rotated array will be  {5, 6, 1, 2,  3,  4} Solution: There are multiple ways to solve this problem. Approach 1: Move each number by […]

  • 03 October

    Search 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 […]

  • 15 October

    Largest sum contiguous subarray

    If you want to practice data structure and algorithm programs, you can go through 100+ java coding interview questions. Problem: From Wikipedia : In computer science, the Largest sum contiguous subarray is the task of finding the contiguous subarray within a one-dimensional array of numbers which has the largest sum. For example, for the sequence of […]

  • 06 October

    Find the Contiguous Subarray with Sum to a Given Value in an array

    Problem : Given an array of positive integer and given value X, find Contiguous sub array whose sum is equal to X. For example: [crayon-60ce1471ea53b893752199/] Solution: Solution 1: Check all sub arrays and if current sum is equal to X, return. This will require two loops and if currentSum is greater than X tben try […]

  • 06 October

    Separate 0s and 1s in an array

    Problem : Given an array of 0’s and 1’s in random order , you need to separate 0’s and 1’s in an array. For example: [crayon-60ce1471eaab1548006136/] Solution : Solution 1: Count number of 0’s in the array. Lets say we get X 0’s Once we get the count, put X 0’s in the array and […]