Find the closest pair to a given sum in two sorted arrays
Given two sorted arrays, find a pair whose sum is closest to a given sum where the pair consists of elements from each array.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven two sorted arrays, find a pair whose sum is closest to a given sum where the pair consists of elements from each array.
Given a binary array, find the index of 0 to be replaced with 1 to get a maximum length sequence of continuous ones using the sliding window technique.
Given a collection of n items, each of which has a non-negative integer key whose maximum value is at most k, effectively sort it using the counting sort algorithm.
Given two binary arrays, X and Y, find the length of the longest continuous sequence that starts and ends at the same index in both arrays and have the same sum. In other words, find max(j-i+1) for every j >= i, where the sum of subarray X[i, j] is equal to the sum of subarray Y[i, j]
Given an array with many duplicated elements, write an algorithm to efficiently sort it in linear time, where the order of equal elements doesn’t matter.
Quicksort exhibits poor performance for inputs that contain many repeated elements. The problem is visible when all the input elements are equal. In this post, we will implement Quicksort efficiently for inputs containing many repeated elements.
In this article, we will implement a ternary search algorithm and compare its performance with binary search algorithm.
Given an array of sorted integers that may contain several duplicate elements, count the total number of distinct absolute values in it.
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
Write code to print all combinations of positive integers in increasing order that sum to a given positive number.
Given an array having elements between 0 and 31, find elements that occur an odd number of times without using the extra space.
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.