## Sort an array using one swap

Given an array where all its elements are sorted except two elements which were swapped, sort the array in linear time. Assume there are no duplicates in the array.

Coding made easy

Given an array where all its elements are sorted except two elements which were swapped, sort the array in linear time. Assume there are no duplicates in the array.

Implement Quicksort algorithm usingĀ Hoare’s Partitioning scheme.

Given an unsorted array of integers, find a triplet with given sum in it.

Given M sorted lists of variable length, print them in sorted order efficiently.

Given two Boolean arrays X and Y, find the length of longest continuous sequence that starts and ends at same index in both arrays and have same sum. In other words, find max(j-i+1) for every j >= i where sum of sub-array X[i, j] is equal to sum of sub-array Y[i, j].

Implement Quicksort efficiently for inputs containing many repeated elements.

In this article, we will implement Ternary Search algorithm and compare its performance with Binary Search.

Given a positive number N, find all combinations of 2*N elements such that every element from 1 to N appears exactly twice and distance between its two appearances is exactly equal to value of the element.

Given an array of integers, find sub-array in it that has maximum product of its elements.

The longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence’s elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique.

Given a list containing future prediction of share prices, find maximum profit that can be earned by buying and selling shares any number of times with constraint that a new transaction can only start after previous transaction is complete. i.e. we can only hold at-most one share at a time.

Find maximum amount of water that can be trapped within given set of bars. Assume width of each bar is 1 unit.

Given a schedule containing arrival and departure time of trains in a station, find minimum number of platforms needed in the station so to avoid any delay in arrival of any train.

Given an array of integers, find the maximum sum of subsequence of given array where subsequence contains no adjacent elements.