## 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 »

## Minimum swaps required to bring all elements less than or equal to k together

Given an array of n positive integers and a number k. Find the minimum number of swaps required to bring all the numbers less than… Read More »

## Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space

We have an array of the form {a0, a1, a2….., an, b0, b1, b2, …..bn} and our task is to rearrange the same in theform… Read More »

## Segregate even and odd numbers | Set 2

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 »

## Rearrange array such that arr[i] >= arr[j] if i is even and arr[i]<=arr[j] if i is odd and j < i

Given an array of n elements. Our task is to write a program to rearrange the array such that elements at even positions are greater… Read More »

## 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… Read More »

## Move all zeroes to end of array | Set-2 (Using single traversal)

Given an array of n numbers. The problem is to move all the 0’s to the end of the array while maintaining the order of… Read More »

## Double the first element and move zero to end

Given an array of integers of size n. Assume ‘0’ as invalid number and all other as valid number. Convert the array in such a… Read More »

## Rearrange array such that even positioned are greater than odd

Given an array A of n elements, sort the array according to the following relations : , if i is even. , if i is… Read More »

## Even numbers at even index and odd numbers at odd index

Given an array of size n containing equal number of odd and even numbers. The problem is to arrange the numbers in such a way… Read More »

## Lambda expression in Python to rearrange positive and negative numbers

Given an array of positive and negative numbers, arrange them such that all negative integers appear before all the positive integers in the array. The… Read More »

## Rearrange positive and negative numbers using inbuilt sort function

Given an array of positive and negative numbers, arrange them such that all negative integers appear before all the positive integers in the array without… Read More »

## Shuffle array {a1, a2, .. an, b1, b2, .. bn} as {a1, b1, a2, b2, a3, b3, ……, an, bn} without using extra space

Given an array of 2n elements in the following format { a1, a2, a3, a4, ….., an, b1, b2, b3, b4, …., bn }. The… Read More »

## Rearrange a binary string as alternate x and y occurrences

Given a binary string s and two integers x and y are given. Task is to arrange the given string in such a way so… Read More »

## Rearrange array such that even index elements are smaller and odd index elements are greater

Given an array, rearrange the array such that : If index i is even, arr[i] <= arr[i+1] If index i is odd, arr[i] >= arr[i+1]… Read More »