Print continuous subarray with maximum sum
Given an integer array, find and print a contiguous subarray with the maximum sum in it.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an integer array, find and print a contiguous subarray with the maximum sum in it.
Given an integer array, check if it contains a subarray having zero-sum.
Given a positive number n, find all combinations of 2×n elements such that every element from 1 to n appears exactly twice and the distance between its two appearances is exactly equal to the value of the element.
Given a binary array, find the index of 0 to be replaced with 1 to get a maximum length sequence of continuous ones.
Given an integer array with all its elements between 1 and n except two elements, which occur twice. Find two duplicate elements without using any extra memory in linear time.
Given an integer array, find the maximum product subarray. In other words, find a subarray that has the maximum product of its elements.
The Longest Increasing Subsequence (LIS) 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 the maximum profit earned by buying and selling shares any number of times with the constraint, a new transaction can only start after the previous transaction is complete.
Trapping rainwater problem: Find the maximum amount of water that can be trapped within a given set of bars where each bar’s width is 1 unit.
Given a schedule containing the arrival and departure time of trains in a station, find the minimum number of platforms needed to avoid delay in any train’s arrival.
Given an integer array, find the maximum sum of subsequence where the subsequence contains no adjacent elements.
Given a set of intervals, print all non-overlapping intervals after merging the overlapping intervals.