# Category Archives: Sorting

## Lexicographically smallest string after M operations

Given a string S and integer M. The task is to perform exactly M operations to get lexicographical smallest string. In each operation, select one… Read More »

## Maximum size subset with given sum using Backtracking

Given an array arr[] consisting of N integers and an integer K, the task is to find the length of longest subsequence with sum equal… Read More »

## Maximize jobs that can be completed under given constraint

Given an integer N denoting number of jobs and a matrix ranges[] consisting of a range [start day, end day] for each job within which… Read More »

## Minimize number of boxes by putting small box inside bigger one

Given an array size[] of box sizes, our task is to find the number of boxes left at the end, after putting the smaller sized… Read More »

## Minimum increment/decrement operations required to make Median as X

Given an array A[] of n odd integers and an integer X. Calculate the minimum number of operations required to make the median of the… Read More »

## Minimum sum obtained by choosing N number from given N pairs

Given an array arr[] of N pairs of integers (A, B) where N is even, the task is to find the minimum sum of choosing… Read More »

## Largest square which can be formed using given rectangular blocks

Given an array arr[] of positive integers where each element of the array represents the length of the rectangular blocks. The task is to find… Read More »

## Count of elements which is product of a pair or an element square

Given an array arr[] of N positive integers, the task is to count the number of array elements which can be expressed as the product… Read More »

## 0/1 Knapsack using Least Count Branch and Bound

Given N items with weights W[0..n-1], values V[0..n-1] and a knapsack with capacity C, select the items such that: The sum of weights taken into… Read More »

## Count of distinct numbers in an Array in a range for Online Queries using Merge Sort Tree

Given an array arr[] of size N and Q queries of the form [L, R], the task is to find the number of distinct values… Read More »

## Sorting algorithm visualization : Insertion Sort

An algorithm like Insertion Sort can be understood easily by visualizing. In this article, a program that visualizes the Insertion Sort Algorithm has been implemented.… Read More »

## Sort a string lexicographically using triple cyclic shifts

Given a string consisting of the first N distinct alphabets, the task is to sort the string by using at most N/2 moves. Each move… Read More »

## Minimize difference after changing all odd elements to even

Given an array arr[] of N positive integers. We have to perform one operation on every odd element in the given array i.e., multiply every… Read More »

## Longest subarray having sum K | Set 2

Given an array arr[] of size N containing integers. The task is to find the length of the longest sub-array having sum equal to the… Read More »

## Find the missing number in unordered Arithmetic Progression

Given an unsorted array arr[] of N integers that are in Arithmetic Progression, the task is to print the missing element from the given series.… Read More »