##
Find four elements that sum to a given value | Set 1 (n^3 solution)
September 4, 2012

Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X.

September 4, 2012

Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X.

August 30, 2012

Given an array of integers, replace every element with the next greatest element (greatest element on the right side) in the array.

July 23, 2012

Given an array that contains both positive and negative integers, find the product of the maximum product subarray. Expected Time complexity is O(n) and only O(1) extra space can be used.

June 26, 2012

Given an array containing only 0s and 1s, find the largest subarray which contain equal no of 0s and 1s. Expected time complexity is O(n).

June 8, 2012

Given an array of n integers, find the 3 elements such that a[i] < a[j] < a[k] and i < j < k in 0(n) time. If there are multiple such triplets, then print any one of them.

May 24, 2012

Given an unsorted array that contains even number of occurrences for all numbers except two numbers. Find the two numbers which have odd occurrences in O(n) time complexity and O(1) extra space.

May 22, 2012

You are given an unsorted array with both positive and negative elements. You have to find the smallest positive number missing from the array in O(n) time using constant extra space. You can modify the original array.

Given an array and a value, find if there is a triplet in array whose sum is equal to the given value. If there is such a triplet present in array, then print the triplet and return true.

May 18, 2012

After few months of gap posting an algo. The current post is pending from long time, and many readers (e.g. here, here, here may be few more, I am not keeping track of all) are posting requests for explanation of the below problem.

May 13, 2012

Given an unsorted array of nonnegative integers, find a continous subarray which adds to a given number.

January 23, 2012

Write a function to count number of smaller elements on right of each element in an array.