Move all zeros present in an array to the end
Given an integer array, move all zeros present in it to the end. The solution should maintain the relative order of items in the array and should not use constant space.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an integer array, move all zeros present in it to the end. The solution should maintain the relative order of items in the array and should not use constant space.
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, find the equilibrium index in it. For an array A consisting n elements, index i is an equilibrium index if the sum of elements of subarray A[0…i-1] is equal to the sum of elements of subarray A[i+1…n-1].
Given an integer array, in-place shuffle it. The algorithm should produce an unbiased permutation, i.e., every permutation is equally likely.
Given an unsorted integer array, find a pair with the given sum in it.
Given an array containing only 0’s, 1’s, and 2’s, sort it in linear time and using constant space.
Given a binary array, sort it in linear time and constant space. The output should print all zeros followed by all ones.
Given an integer array, rearrange it such that every second element becomes greater than its left and right elements. Assume no duplicate elements are present in the array.
Given a set of positive numbers, find all possible combinations of words formed by replacing the continuous digits with the English alphabet’s corresponding character.
The longest alternating subsequence is a problem of finding a subsequence of a given sequence in which the elements are in alternating order and in which the sequence is as long as possible.
Given an unlimited supply of coins of given denominations, find the total number of distinct ways to get the desired change.
Coin change-making problem: Given an unlimited supply of coins of given denominations, find the minimum number of coins required to get the desired change.