Trapping Rain Water Problem
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.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedTrapping 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.
This post discusses std::prev_permutation, which can be used to find the lexicographically smaller permutations of a string.
Given a set of intervals, print all non-overlapping intervals after merging the overlapping intervals.
Given a circular integer array, find a subarray with the largest sum in it.
Given an integer array, find a contiguous subarray within it that has the largest sum using Kadane’s algorithm.
The Longest Bitonic Subarray (LBS) problem is to find a subarray of a given sequence in which the subarray’s elements are first sorted in increasing order, then in decreasing order, and the subarray is as long as possible.
This post discusses std::next_permutation, which can be used to find the lexicographically greater permutations of a string.
Given an integer array containing duplicates, return the majority element if present. A majority element appears more than n/2 times, where n is the array size.
Given an integer array, in-place shuffle it. The algorithm should produce an unbiased permutation, i.e., every permutation is equally likely.
Given an array containing only 0’s, 1’s, and 2’s, sort it in linear time and using constant space.
Deletion from BST – write an efficient function to delete a given key in BST. To delete a node from BST, there are three possible cases to consider.
Given a BST, write an efficient function to search a given key in it. The algorithm should return the parent node of the key and print if the key is the left or right node of the parent node. If the key is not present in the BST, the algorithm should be able to determine that.