# Category Archives: Searching

## Pair with given sum and maximum shortest distance from endNovember 17, 2017

Given an array of N integers and an integer K, pick two distinct elements whose sum is K and find the maximum shortest distance of… Read More »

## Largest number less than or equal to N in BST (Iterative Approach)November 13, 2017

We have a binary search tree and a number N. Our task is to find the greatest number in the binary search tree that is… Read More »

## Find if given number is sum of first n natural numbersNovember 12, 2017

Given a number s (1 n, r = mid – 1. e) Else sum < n, l = mid + 1. 3- Return -1, if… Read More »

## Save from Bishop in chessboardNovember 11, 2017

ou are given a 8*8 chess board. Along with the chess board there is a Bishop placed on board and its position is known. Position… Read More »

## Counting cross lines in an arrayNovember 5, 2017

Given an unsorted array of distinct elements. Task is to count number of cross lines formed in an array elements after sorting the array elements.… Read More »

## Quickselect AlgorithmNovember 4, 2017

Quickselect is a selection algorithm to find the k-th smallest element in an unordered list. It is related to the quick sort sorting algorithm. Examples:… Read More »

## Find four missing numbers in an array containing elements from 1 to NNovember 1, 2017

Given an array of unique integers where each integer of the given array lies in the range [1, N]. The size of array is (N-4).… Read More »

## Count ways to form minimum product triplets

Given an array of positive integers. We need to find how many triples of indices (i, j, k) (i < j < k), such that… Read More »

## Minimum absolute difference of adjacent elements in a circular arrayOctober 28, 2017

Given n integers, which form a circle. Find the minimal absolute value of any adjacent pair. If there are many optimum solutions, output any of… Read More »

## Divide an array into k segments to maximize maximum of segment minimumsOctober 19, 2017

Given an array of n integers, divide it into k segments and find the maximum of the minimums of k segments. Output the maximum integer… Read More »

## k-th missing element in increasing sequence which is not present in a given sequenceOctober 17, 2017

Given two sequences, one is increasing sequence a[] and another a normal sequence b[], find the K-th missing element in the increasing sequence which is… Read More »

## Count number of elements between two given elements in arrayOctober 16, 2017

Given an unsorted array of n elements and also given two points num1 and num2. The task is to count number of elements occurs between… Read More »

## Sort a Rotated Sorted ArrayOctober 11, 2017

You are given a rotated sorted array and your aim is to restore its original sort in place. Expected to use O(1) extra space and… Read More »

## Count ways of choosing a pair with maximum differenceOctober 8, 2017

Given an array of n integers, we need to find the no. of ways of choosing pairs with maximum difference. Examples: Input : a[] =… Read More »

## Minimum product pair an array of positive IntegersSeptember 29, 2017

Given an array of positive integers. We are required to write a program to print the minimum product of any two numbers of the given… Read More »