# Category Archives: Sorting (adsbygoogle = window.adsbygoogle || []).push({});

## Floor of every element in same array

Given an array of integers, find the closest smaller or same element for every element. If all elements are greater for an element, then print… Read More »

## Minimum range increment operations to Sort an array

Given an array containing N elements. It is allowed to do the below move any number of times on the array: Choose any L and… Read More »

## Find closest value for every element in array

Given an array of integers, find the closest element for every element. Examples: Input : arr[] = {10, 5, 11, 6, 20, 12} Output :… Read More »

## Check if array can be sorted with one swap

Given an array containing N elements. Find if it is possible to sort it in non-decreasing order using atmost one swap. Examples: Input : arr[]… Read More »

## Find a point that lies inside exactly K given squares

Given an integer K and an array arr each of whose element x represents a square with two of its vertices as (0, 0) and… Read More »

## Sorting rows of matrix in descending order followed by columns in ascending order

Given a matrix of distinct elements. The task is to sort the rows of matrix in descending order followed by sorting the columns in ascending… Read More »

## Minimum number of increment/decrement operations such that array contains all elements from 1 to N

Given an array of N elements, the task is to convert it into a permutation (Each number from 1 to N occurs exactly once) by… Read More »

## Print the nodes of binary tree as they become the leaf node

Given a binary tree. First print all leaf nodes, after that remove all the leaf nodes from the tree and now print all the new… Read More »

## Minimum sum after subtracting multiples of k from the elements of the array

Given an integer and an integer array , the task is to find the minimum possible sum of all the elements of the array after… Read More »

## Print a case where the given sorting algorithm fails

Given an integer N, the task is to find N elements which fail the below-sorting algorithm. If none of the N elements fail, then print… Read More »

## In-Place Merge Sort

Implement Merge Sort i.e. standard implementation keeping the sorting algorithm as in-place. In-place means it does not occupy extra memory for merge operation as in… Read More »

## Find the missing elements from 1 to M in given N ranges

Given segments as ranges [L, R] where ranges are non-intersecting and non-overlapping. The task is to find all number between 1 to that doesn’t belong… Read More »

## Minimum Increment / decrement to make array elements equal

Given an array of integers where . In one operation you can either Increment/Decrement any element by 1. The task is to find the minimum… Read More »

## Count elements such that there are exactly X elements with values greater than or equal to X

Given an array arr of N integers, the task is to find the number of elements that satisfy the following condition: If the element is… Read More »

## Check whether it is possible to make both arrays equal by modifying a single element

Given two sequences of integers ‘A’ and ‘B’, and an integer ‘k’. The task is to check if we can make both sequences equal by… Read More »