Given an unsorted array and a number n, find if there exists a pair of elements in the array whose difference is n. Examples:...
Given an array of even number of elements, form groups of 2 using these array elements such that the difference between the group with highest sum and the one with lowest sum is maximum.Note: An element can be a part of one group only and it has to be a part of at least 1 group. Examples:...
You are given an array A[] of n-elements and a positive integer k (k > 1). Now you have find the number of pairs Ai, Aj such that Ai = Aj*(kx) where x is an integer. Note: (Ai, Aj) and (Aj, Ai) must be count once.Examples :...
Given a linked list and a key in it, the task is to move all occurrences of the given key to the end of the linked list, keeping the order of all other elements the same....
You are given an array on n-elements. An extrema is an elements which is either greater than its both of neighbors or less than its both neighbors. You have to calculate the number of local extrema in given array. Note : 1st and last elements are not extrema.Examples :...
Given a matrix, the task is to find the maximum element of each row.Examples:...
Given N numbers with no duplicates, count the number of unique triplets (ai, aj, ak) such that their XOR is 0. A triplet is said to be unique if all of the three numbers in the triplet are unique....
Given a sorted array of distinct positive integers, print all triplets that form AP (or Arithmetic Progression)Examples :...
Write a PHP program for a given array arr[], count the number of pairs arr[i], arr[j] such that arr[i] + arr[j] is maximum and i < j....
Given a numeric string S, the task is to find the maximum length of a subsequence having its left rotation equal to its right rotation....
Given an array arr[], the task is to find the number of rotations required to convert the given array to sorted form.Examples:...
You are given an array on n-elements. An extrema is an elements which is either greater than its both of neighbors or less than its both neighbors. You have to calculate the number of local extrema in given array. Note : 1st and last elements are not extrema.Examples :...