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, 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.
4-sum problem: Given an unsorted integer array, check if it contains four elements tuple (quadruplets) having a given sum.
Given an unsorted linked list, write a function that deletes any duplicate nodes from the list by traversing it only once.
Given an unsorted integer array, find a triplet with a given sum in it.
Given an integer array having distinct elements, find the surpasser count for each element in it. In other words, for each array element, find the total number of elements to its right, which are greater than it.
Given an array and an integer k, find the count of distinct elements in every subarray of size k.
Given an integer array, print all maximum size subarrays having all distinct elements in them.
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.
Given an N × N ancestor matrix, whose cell (i, j) has the value true if i is the ancestor of j in a binary tree, construct a binary tree from it where binary tree nodes are labeled from 0 to N-1.