Remove adjacent duplicate characters from a string
Given a string, remove adjacent duplicates characters from it. In other words, remove all consecutive same characters except one.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a string, remove adjacent duplicates characters from it. In other words, remove all consecutive same characters except one.
Given two arrays of positive integers, add their elements into a new array. The solution should add both arrays, one by one starting from the 0th index, and split the sum into individual digits if it is a 2–digit number
Given a huge set of words with duplicates present, find the maximum occurring word in it. If two words have the same count, return any one of them.
Quicksort performance can be boosted in several ways. In this post, we will cover a few of them.
Given an integer array, find a contiguous subarray within it that has the largest sum using Kadane’s algorithm.
Given an integer array, find the maximum product of two integers in it. For example, consider array {-10, -3, 5, 6, -2}. The maximum product is the (-10, -3) or (5, 6) pair.
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.
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 unsorted integer array, find a pair with the given sum in it.
Given a binary array, sort it in linear time and constant space. The output should print all zeros followed by all ones.
Given a BST and a positive number k, find the k’th largest node in the BST.