#
java programs Archive

Kadane algorithm is a famous algorithm to solve maximum subarray problem. Maximum subArray problem: From Wikipedia : In computer science, the maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional …

Problem : Given an array of positive integer and given value X, find Contiguous sub array whose sum is equal to X. For example: Solution: Solution 1: Check all sub arrays and if current …

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: Solution : Solution 1: Count number of 0’s in …

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 minimum element in sorted and rotated array. …

Given array of integers, find Maximum difference between two elements such that larger element appears after the smaller number For example: Algorithm: Lets say we have array arr of stock prices. We will track two variable :minElementTillNow and maxDifference. …

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: Algorithm: Lets say array is …

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: Solution: Solution 1: Use two loops. Outer …

If you want to practice data structure and algorithm programs, you can go through data structure and algorithm interview questions. Given an array of integers representing stock price on single day, find max profit that can …

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 …

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 …