Replace every array element with the least greater element on its right
Write an efficient algorithm to replace every element of a given array with the least greater element on its right or with -1 if there are no greater elements.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedWrite an efficient algorithm to replace every element of a given array with the least greater element on its right or with -1 if there are no greater elements.
The Longest Common Subsequence (LCS) problem is finding the longest subsequence present in given two sequences in the same order, i.e., find the longest sequence which can be obtained from the first original sequence by deleting some items and from the second original sequence by deleting other items.
Find all n–digit strictly increasing numbers where n varies from 1 to 9. If we process the number from left to right and every digit is greater than the preceding digit, we can say that the number is strictly increasing.
Given a binary tree, write an efficient algorithm to check if a tree is height-balanced or not. In a height-balanced tree, the absolute difference between the height of the left and right subtree for every node is 0 or 1.
Given an integer array, find and print a contiguous subarray with the maximum sum in it.
Given a dictionary of words where each word follows a CamelCase notation, find all words in it that matches a given pattern of all uppercase characters.
Find the longest common prefix (LCP) in a given set of strings.
Lexicographic sorting: Given a set of strings, print them in lexicographic order (dictionary/alphabetical order).
Given a huge set of words with duplicates present and a positive integer k, find the first k–maximum occurring words in it.
Find duplicate rows present in a given binary matrix by traversing the matrix only once.
Given a dictionary of words, determine if a given string can be segmented into a space-separated sequence of one or more dictionary words.
Given an integer array, check if it contains a subarray having zero-sum.