Find the minimum difference between the index of two given elements present in an array
Given two integers, find the minimum difference between their index in a given array in linear time and a single traversal of the array.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven two integers, find the minimum difference between their index in a given array in linear time and a single traversal of the array.
Given an integer array, partition it into two subarrays having the same sum of elements.
Given an array of distinct integers, replace each array element by its corresponding rank in the array. The minimum array element has the rank 1; the second minimum element has a rank of 2, and so on…
Print binary representation of a given number in C, C++, Java, and Python using built-in methods and custom routines.
Given an integer array, find the minimum index of a repeating element in linear time and doing just one traversal of the array.
Given a sorted integer array, find a pair in it having an absolute minimum sum.
Given a binary tree, efficiently clone of it.
Given two sorted integer arrays, merge them into a single array in decreasing order, and return it. In other words, merge two sorted arrays from their end.
Given two integer arrays, each of which is sorted in increasing order, merge them into a single array in increasing order, and return it.
Given an integer array, find the index of the maximum occurring element with an equal probability.
Given an M × N rectangular grid, efficiently count all paths starting from the first cell (0, 0) to the last cell (M-1, N-1). We can either move down or move towards right from a cell.
Given a positive number, find the square root of it. If the number is not a perfect square, then return the floor of its square root.