# Tag Archives: array-rearrange (adsbygoogle = window.adsbygoogle || []).push({});

## Length of the longest alternating subarray

Given an array of N including positive and negative numbers only. The task is to find the length of the longest alternating (means negative-positive-negative or… Read More »

## Arrange first N natural numbers such that absolute difference between all adjacent elements > 1

Given an integer N. The task is to find the permutation of first N natural numbers such that the absolute difference between any two consecutive… Read More »

## Rearrange Odd and Even values in Alternate Fashion in Ascending Order

Given an array of integers (both odd and even), the task is to arrange them in such a way that odd and even values come… Read More »

## Rearrange an array to maximize i*arr[i]

Given an array of N integers, you have to select all of these integers in any order. For every integer you select, you get points… Read More »

## Rearrange all elements of array which are multiples of x in increasing order

Given an array of integers ‘arr’ and a number x, the task is to sort all the elements which are multiples of x of the… Read More »

## Arrange a binary string to get maximum value within a range of indices

Given a string consisting of only 0’s and 1’s. Now you are given N non-intersecting ranges L, R ( L <= R), more specifically [L1,… Read More »

## Maximum number of fixed points using atmost 1 swap

Given a permutation of N elements (Elements are in range 0 to N-1). A fixed point is an index at which the value is same… Read More »

## Split the array and add the first part to the end | Set 2

Given an array and split it from a specified position, and move the first part of array add to the end. Examples: Input : arr[]… Read More »

## Segregating negative and positive maintaining order and O(1) space

Segregation of negative and positive numbers in an array without using extra space, and maintaining insertion order and in O(n) time complexity. Examples: Input :9… Read More »

## In-Place Algorithm

In-place has more than one definitions. One strict definition is. An in-place algorithm is an algorithm that does not need an extra space and produces… Read More »

## Minimum number of adjacent swaps for arranging similar elements together

Given an array of 2 * N positive integers where each array element lies between 1 to N and appears exactly twice in the array.… Read More »

## Partition negative and positive without comparison with 0

Given an array of n integers, both negative and positive, partition them into two different arrays without comparing any element with 0. Examples: Input :… Read More »

## Segregate even and odd numbers | Set 3

Given an array of integers, segregate even and odd numbers in the array. All the even numbers should be present first, and then the odd… Read More »

## Replace two consecutive equal values with one greater

You are given an array of size ‘n’. You have to replace every pair of consecutive values ‘x’ by a single value ‘x+1’ every time… Read More »

## Move matrix elements in given direction and add elements with same value

Given a matrix m[ ][ ] of size n x n consisting of integers and given a character ‘x’ indicating the direction. Value of ‘x’… Read More »