# Category Archives: Arrays

## Rearrange array to obtain maximum possible value of concatenation of prefix GCDs

Given an array arr[] consisting of N positive integers, the task is to rearrange the array elements such that the number formed by concatenating the… Read More »

## Count greater elements on the left side of every array element

Given an array arr[] of distinct integers of size N, the task is to print the count of greater elements on the left side of… Read More »

## Minimum common element in all subarrays of size K

Given an array arr[] consisting of N distinct integers and a positive integer K, the task is to find the minimum element that occurs in… Read More »

## Smallest array that can be obtained by replacing adjacent pairs with their products

Given an array arr[] of size N, the task is to print the least possible size the given array can be reduced to by performing… Read More »

## Maximum XOR of Two Numbers in an Array | Set 2

Given an array arr[] consisting of N integers, the task is to find the maximum Bitwise XOR from all the possible pairs in the given… Read More »

## Array obtained by repeatedly reversing array after every insertion from given array

Given an array arr[], the task is to print the array obtained by inserting elements of arr[] one by one into an initially empty array,… Read More »

## Queries to find the future closest date

Given an array arr[] consisting of N strings and an array Query[] consisting of Q queries. Each string in arrays arr[] and Query[] is of… Read More »

## Subarrays whose sum is a perfect square

Given an array, arr[] of size N, the task is to print the start and end indices of all subarrays whose sum is a perfect… Read More »

## Maximize length of subarray having equal elements by adding at most K

Given an array arr[] consisting of N positive integers and an integer K, which represents the maximum number that can be added to the array… Read More »

## Pair having all other given pairs lying between its minimum and maximum

Given a 2D array arr[][] consisting of N pairs of integers, the task is to find the pair which covers all other pairs of the… Read More »

## Subarray of length K having concatenation of its elements divisible by X

Given an array arr[] consisting of N positive integers, the task is to find a subarray of length K such that concatenation of each element… Read More »

## Count squares possible from M and N straight lines parallel to X and Y axis respectively

Given two arrays X[] and Y[] consisting of N and M integers such that there are N lines parallel to the y-axis and M lines… Read More »

## Print Stack Elements from Top to Bottom

Given a Stack S, the task is to print the elements of the stack from top to bottom such that the elements are still present… Read More »

## Rearrange string to obtain Longest Palindromic Substring

Given string str, the task is to rearrange the given string to obtain the longest palindromic substring. Examples: Input: str = “geeksforgeeks”Output: eegksfskgeeorExplanation: eegksfskgee is… Read More »

## Rearrange array to maximize count of triplets (i, j, k) such that arr[i] > arr[j] < arr[k] and i < j < k

Given an array, arr[] of size N, the task is to rearrange the array elements to maximize the count of triplets (i, j, k) that… Read More »