## Order of indices which is lexicographically smallest and sum of elements is <= X

Given an array arr[] and an integer X, the task is to find the indices such that: The sum of elements on the found indices… Read More »

## Find minimum difference between any two elements | Set 2

Given an unsorted array arr[] of size n, the task is to find the minimum difference between any pair in the given array. Input: arr[]… Read More »

## Longest subsequence with first and last element greater than all other elements

Given a permutation from 1 to N of size N. Find the length of the longest subsequence having the property that the first and last… Read More »

## Number of sub-sequence such that it has one consecutive element with difference less than or equal to 1

Given an array arr[] of N elements. The task is to find the number of sub-sequences which have at least two consecutive elements such that… Read More »

## Iterative approach to print all permutations of an Array

Given an array arr[] of size N, the task is to generate and print all permutations of the given array. Examples: Input: arr[] = {1,… Read More »

## Rearrange numbers in an array such that no two adjacent numbers are same

Given an array of integers. The task is to rearrange elements of the array such that no two adjacent elements in the array are same.… Read More »

## Create a Sorted Array Using Binary Search

Given an array, the task is to create a new sorted array in ascending order from the elements of the given array. Examples: Input :… Read More »

## Maximum sum of non-overlapping subarrays of length atmost K

Given an integer array ‘arr’ of length N and an integer ‘k’, select some non-overlapping subarrays such that each sub-array if of length at most… Read More »

## Generate elements of the array following given conditions

Given an integer N, for every integer i in the range 2 to N, assign a positive integer such that the following conditions hold :… Read More »

## Print elements of an array according to the order defined by another array | set 2

Given two arrays a1[] and a2[], print elements of a1 in such a way that the relative order among the elements will be the same… Read More »

## Iterative approach to print all combinations of an Array

Given an array arr[] of size N, the task is to generate and print all possible combinations of R elements in array. Examples: Input: arr[]… Read More »

## Longest sub-sequence that satisfies the given conditions

Given an array arr[] of N integers, the task is to find the longest sub-sequence in the given array such that for all pairs from… Read More »

## Sum of Bitwise OR of all pairs in a given array

Given an array “arr[0..n-1]” of integers. The task is to calculate the sum of Bitwise OR of all pairs, i.e. calculate the sum of “arr[i]… Read More »

## Sum of all mersenne numbers present in an array

Given an array of integers arr[], the task is to find the sum of all the Mersenne numbers from the array. A number is a… Read More »

## Maximum subset sum such that no two elements in set have same digit in them

Given an array of N elements. Find the subset of elements which has maximum sum such that no two elements in the subset has common… Read More »