Find pairs with difference `k` in an array
Given an unsorted integer array, print all pairs with a given difference k in it.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an unsorted integer array, print all pairs with a given difference k in it.
Given a sorted array containing duplicates, efficiently find each element’s frequency without traversing the whole array.
Given an integer array, determine the index of an element before which all elements are smaller and after which all are greater.
Given an integer array, duplicates are present in it in a way that all duplicates appear an even number of times except one which appears an odd number of times. Find that odd appearing element in linear time and without using any extra memory.
Given an integer array, find the minimum and maximum element present in it by making minimum comparisons by using the divide-and-conquer technique.
Given an unsorted linked list, write a function that deletes any duplicate nodes from the list by traversing it only once.
Given an array where all its elements are sorted except two swapped elements, sort it in linear time. Assume there are no duplicates in the array.
This post covers a variation of counting sort that can work on negative numbers and can sort numbers in any range.
Given an N × N matrix, check if it is a Toeplitz matrix or not. A Toeplitz matrix or diagonal-constant matrix is a matrix in which each descending diagonal from left to right is constant.
Write an efficient algorithm to print the two-dimensional view of a binary tree.
Given an integer array between 0 and 9, find two numbers with maximum sum formed using all the array digits. The difference in the number of digits of the two numbers should be ± 1.
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.