# Tag Archives: array-rearrange

## Rearrange an array such that product of every two consecutive elements is a multiple of 4

Given an array arr[] of size N, the task is to rearrange the array elements such that for every index i(1 <= i <= N… Read More »

## Sort Array such that smallest is at 0th index and next smallest it at last index and so on

Given an array, arr[] of N integers, the task is to rearrange the array elements such that the smallest element is at the 0th position,… Read More »

## Find initial sequence that produces a given Array by cyclic increments upto index P

Given an array arr[] consisting of N elements and an integer P, the task is to find the initial array from which given arr[] is… Read More »

## Minimize swaps to rearrange array such that parity of index and corresponding element is same

Given an array A[], the task to find minimum swapping operations required to modify the given array A[] such that for every index in the… Read More »

## Reorder an array such that sum of left half is not equal to sum of right half

Given an array arr[] of even length, the task is to check whether is it possible to reorder the array element such that the sum… Read More »

## Count of triplets of numbers 1 to N such that middle element is always largest

Given an integer N, the task is to count the number of ways to arrange triplets (a, b, c) within [1, N] in such a… Read More »

## Maximize number of groups formed with size not smaller than its largest element

Given an array arr[] of N positive integers(1 ≤ arr[i] ≤ N ), divide the elements of the array into groups such that the size… Read More »

## Reorder an Array according to given indices with repetition allowed

Given two integer arrays arr and index of size N, the task is to create a new array by inserting the elements given in the… Read More »

## Sort an Array based on the absolute difference of adjacent elements

Given an array arr[] containing N integers, the task is to rearrange all the elements of array such that absolute difference between consecutive elements of… Read More »

## Maximize the number of indices such that element is greater than element to its left

Given an array arr[] of N integers, the task is to maximize the number of indices such that an element is greater than the element… Read More »

## Maximum sum after rearranging the array for K queries

Given two arrays arr[] containing N integers and Q[][] containing K queries where every query represents a range [L, R]. The task is to rearrange… Read More »

## Count of distinct XORs formed by rearranging two Binary strings

Given two binary strings A and B of equal length N, the task is to find the number of distinct XORs possible by arbitrarily reordering… Read More »

## Largest number in given Array formed by repeatedly combining two same elements

Given an array arr[], the task is to find the largest number in given Array, formed by repeatedly combining two same elements. If there are… Read More »

## Arrange the array such that upon performing given operations an increasing order is obtained

Given an array arr[] of size N, the task is to print the arrangement of the array such that upon performing following operations on this… Read More »

## Program to print an array in Pendulum Arrangement with constant space

Given an array arr[] of integers, the task is to arrange them in a way similar to the to-and-fro movement of a Pendulum without using… Read More »