Array Rearrangement Last Updated : 23 Aug, 2024 Comments Improve Suggest changes Like Article Like Report Arrays are fundamental data structures in programming, allowing us to store and manipulate collections of related data. One common operation we may need to perform on arrays is rearranging their elements. Array rearrangement can serve various purposes, such as sorting the elements, reversing the order, or positioning specific elements in desired locations. In this article, we'll explore problem based on arranging array elements. Practice Problems on Array Rearrangement: Rearrange an array such that arr[i] = i Write a program to reverse an array or string Rearrange array such that arr[i] >= arr[j] if i is even and arr[i]<=arr[j] if i is odd and j < i Rearrange positive and negative numbers in O(n) time and O(1) extra space Rearrange array in alternating positive & negative items with O(1) extra space | Set 1 Move all zeroes to end of array Move all zeroes to end of array | Set-2 (Using single traversal) Minimum swaps required to bring all elements less than or equal to k together Rearrange positive and negative numbers using inbuilt sort function Rearrange array such that even positioned are greater than odd Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest, .. Double the first element and move zero to end Reorder an array according to given indexes Rearrange positive and negative numbers with constant extra space Arrange given numbers to form the biggest number Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’ Rearrange an array in maximum minimum form | Set 1 Rearrange an array in maximum minimum form | Set 2 (O(1) extra space) Move all negative numbers to beginning and positive to end with constant extra space Move all negative elements to end in order with extra space allowed Rearrange array such that even index elements are smaller and odd index elements are greater Positive elements at even and negative at odd positions Replace every array element by multiplication of previous and next Shuffle a given array Segregate even and odd numbers Segregate 0s and 1s in an array Longest Bitonic Subsequence Find a sorted subsequence of size 3 in linear time Largest subarray with equal number of 0s and 1s Maximum Product Sub-array Replace every element with the greatest element on right side Maximum circular subarray sum Construction of Longest Increasing Subsequence (N log N) Sort elements by frequency | Set 2 Maximize sum of consecutive differences in a circular array Sort an array according to the order defined by another array Find Index of 0 to be replaced with 1 to get longest continuous sequence of 1s in a binary array Three way partitioning of an array around a given range Generate all possible sorted arrays from alternate elements of two given sorted arrays Minimum number of swaps required for arranging pairs adjacent to each other Convert array into Zig-Zag fashion Form minimum number from given sequence Replace two consecutive equal values with one greater Rearrange a binary string as alternate x and y occurrences Distinct adjacent elements in an array Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space Merge k sorted arrays Quick Links : 'Practice Problems' on Arrays 'Quizzes' on Arrays 'Video Tutorials' on Arrays Comment More infoAdvertise with us Next Article Array Rearrangement H harendrakumar123 Follow Improve Article Tags : DSA Arrays Practice Tags : Arrays Similar Reads Rearrange an array such that arr[i] = i Given an array of elements of length n, ranging from 0 to n - 1. All elements may not be present in the array. If the element is not present then there will be -1 present in the array. Rearrange the array such that arr[i] = i and if i is not present, display -1 at that place.Examples: Input: arr[] = 13 min read Array range queries over range queries Given an array of size n and a give set of commands of size m. The commands are enumerated from 1 to m. These commands can be of the following two types of commands: Type 1 [l r (1 <= l <= r <= n)] : Increase all elements of the array by one, whose indices belongs to the range [l, r]. In th 15+ min read Find the Prefix-MEX Array for given Array Given an array A[] of N elements, the task is to create a Prefix-MEX array for this given array. Prefix-MEX array B[] of an array A[] is created such that MEX of A[0] till A[i] is B[i]. MEX of an array refers to the smallest missing non-negative integer of the array. Examples: Input: A[] = {1, 0, 2, 13 min read Deleting Elements in an Array - Array Operations In this post, we will look into deletion operation in an Array, i.e., how to delete an element from an Array, such as:Delete an Element from the Beginning of an ArrayDelete an Element from a Given Position in an ArrayDelete First Occurrence of Given Element from an ArrayRemove All Occurrences of an 4 min read Array Data Structure Complete Guide to ArraysLearn more about Array in DSA Self Paced CoursePractice Problems on ArraysTop Quizzes on Arrays What is Array?An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calcul 3 min read Like