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

## Sort the matrix row-wise and column-wise

Given a n x n matrix. The problem is to sort the matrix row-wise and column wise. Examples: Input : mat[][] = { {4, 1,… Read More »

## Sort the given matrix

Given a n x n matrix. The problem is to sort the given matrix in strict order. Here strict order means that matrix is sorted… Read More »

## Sort an array using socket programming in C

Given an array of unsorted positive integer, sort the given array using the Socket programming . Examples: Input : 4 5 6 1 8 2… Read More »

## Ropes left after every removal of smallest

Given an array of an integer of size, N. Array contains N ropes of length Ropes[i]. You have to perform a cut operation on ropes… Read More »

## Stable sort for descending order

Given an array of n integers, we have to reverse sort the array elements such the equal keys are stable after sorting. Examples: Input :… Read More »

## Lexicographical concatenation of all substrings of a string

Given a string, find concatenation of all substrings in lexicographic order. Examples: Input : s = “abc” Output : aababcbbcc The substrings of s in… Read More »

## Row wise sorting in 2D array

Given a 2D array, sort each row of this array and print the result. Examples: Input : 77 11 22 3 11 89 1 12… Read More »

## Find number of pairs in an array such that their XOR is 0

Given an array of size N. Find the number of pairs (i, j) such that XOR = 0, and 1 <= i < j <=… Read More »

## Median and Mode using Counting Sort

Given an n sized unsorted array, find median and mode using counting sort technique. Thia can be useful when array elements are in limited range.… Read More »

## Find k maximum elements of array in original order

Given an array arr[] and an integer k, we need to print k maximum elements of given array. The elements should printed in the order… Read More »

## Check if both halves of the string have at least one different character

Earlier we have discussed on how to check if both halves of the string have same set of characters. Now, we further extend our problem… Read More »

## Subtraction in the Array

Given an integer k and an array arr[], the task is to repeat the following operation exactly k times: Find the minimum non-zero element in… Read More »

## Closest numbers from a list of unsorted integers

Given a list of distinct unsorted integers, find the pair of elements that have the smallest absolute difference between them? If there are multiple pairs,… Read More »

## Insertion Sort by Swapping Elements

Insertion Sort is suitable for arrays of small size. It also achieves best-case complexity of O(n) if the arrays are already sorted. We have discussed… Read More »

## Rank of all elements in an array

Given an array of N integers with duplicates allowed. All elements are ranked from 1 to N in ascending order if they are distinct. If… Read More »