## Rearrange given Array in Maximum Minimum Form

Problem Statement In the “Rearrange given Array in Maximum Minimum Form” problem, we have given a sorted array containing N elements. Rearrange the given sorted array of positive integers, such that alternative elements are ith max and ith min. See below for a better understanding of rearrangement of elements- Array …

## Subarray and Subsequence

Problem Statement In the subarray and subsequence problem, we have to print all the subarrays and subsequences for a given array. Generate all possible non-empty subarrays. A subarray is commonly defined as a part or section of an array in which the contiguousness is based on the index. The subarray …

## Merge Two Sorted Arrays

Problem Statement In merge two sorted arrays problem, we have given two input sorted arrays, we need to merge these two arrays such that the initial numbers after complete sorting should be in the first array and remaining in the second array. Example Input A[] = {1, 3, 5, 7, …

## Count of Triplets With Sum Less than Given Value

Problem Statement We have given an array containing N number of elements. In the given array, Count the number of triplets with a sum less than the given value. Example Input a[] = {1, 2, 3, 4, 5, 6, 7, 8} Sum = 10 Output 7 Possible triplets are : …

## Reorder Array Using Given Indexes

Problem Statement In recorder array using given indexes problem we have given two input arrays of the same size, the second array is index array, we need to reorder elements in the same array according to given index array. Example Input array : [4, 2, 1, 3] index : [3, …

## Next Greater Element in an Array

Problem Statement Given an array, we will find the next greater element of each element in the array. If there is no next greater element for that element then we will print -1, else we will print that element. Note: Next greater element is the element that is greater and …

## Merging Two Sorted Arrays

Problem Statement In merging two sorted arrays problem we have given two sorted arrays, one array with size m+n and the other array with size n. We will merge the n sized array into m+n sized array and print the m+n sized merged array. Example Input 6 3 M[] = …

## Reorder an Array According to the Given Indexes

Problem Statement Given an input array and the array of indexes, reorder an array according to the given indexes. Here we have to arrange the elements according to the indexes as per the given index array. Example Input : arr[] = [23,24,25] and given indexes are index[] = [1,0,2] 23 …

## Find Element Using Binary Search in Sorted Array

Problem Statement Given a sorted array, Find element using binary search in the sorted array. If present, print the index of that element else print -1. Example Input arr[] =  {1, 6, 7, 8, 9, 12, 14, 16, 26, 29, 36, 37, 156} X = 6 //element to be searched …

## Find Triplet in Array With a Given Sum

Problem Statement Given an array of integers, find the combination of three elements in the array whose sum is equal to a given value X. Here we will print the first combination that we get. If there is no such combination then print -1. Example Input N=5, X=15 arr[] = …

Translate »