# Category Archives: Searching

## De-arrangements for minimum product sum of two arrays

Given two arrays A[] and B[] of same size n. We need to first permute any of arrays such that the sum of product of… Read More »

## Find last index of a character in a string

Given a string str and a character x, find last index of x in str. Examples : Input : str = “geeks”, x = ‘e’… Read More »

## Print pair with maximum AND value in an array

Given an array of n positive elements, find the maximum AND value and the pair of elements generating the maximum AND value from the array.… Read More »

## Probability of choosing a random pair with maximum sum in an array

Given an array of N integers, You have to find the probability of choosing a random pair(i, j), i < j such that A[i] +… Read More »

## Count pairs in array whose sum is divisible by 4

Given a array if ‘n’ positive integers. Count number of pairs of integers in the array that have the sum divisible by 4. Input: {2,… Read More »

## Middle of three using minimum comparisons

Given three distinct numbers a, b and c find the number with a value in middle. Examples : Input : a = 20, b =… Read More »

## Print n smallest elements from given array in their original order

We are given an array of m-elements, we need to find n smallest elements from the array but they must be in the same order… Read More »

## Even-odd turn game with two integers

Given three positive integers X, Y and P. Here P denotes the number of turns. Whenever the turn is odd X is multiplied by 2… Read More »

## The painter’s partition problem | Set 2

We have to paint n boards of length {A1, A2, .. An}. There are k painters available and each takes 1 unit time to paint… Read More »

## Product of maximum in first array and minimum in second

Given two arrays, the task is to calculate the product of max element of first array and min element of second array References : Asked… Read More »

## Grouping Countries

People in a group, are sitting in a row numbered from 1 to n. Every has been asked the same question, “How many people of… Read More »

## Minimum De-arrangements present in array of AP (Arithmetic Progression)

Given an array of n-elements. Given array is a permutation of some Arithmetic Progression. Find the minimum number of De-arrangements present in that array so… Read More »

## Program to find the minimum (or maximum) element of an array

Given an array, write functions to find minimum and maximum elements in it. Output: Minimum element of array: 1 Maximum element of array: 1234 Time… Read More »

## No of pairs (a[j] >= a[i]) with k numbers in range (a[i], a[j]) that are divisible by x

Given an array and two numbers x and k. Find the number of different ordered pairs of indexes (i, j) such that a[j] >= a[i]… Read More »

## Probability of a random pair being the maximum weighted pair

Given two arrays A and B, a random pair is picked having an element from array A and another from array B. Output the probability… Read More »