Count Sort – C++, Java, and Python Implementation
This post covers a variation of counting sort that can work on negative numbers and can sort numbers in any range.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedThis post covers a variation of counting sort that can work on negative numbers and can sort numbers in any range.
Given an unsorted integer array, find a triplet with a given sum in it.
Given an integer array having distinct elements, find the surpasser count for each element in it. In other words, for each array element, find the total number of elements to its right, which are greater than it.
Given M sorted lists of variable length, print them efficiently in sorted order.
Introsort is an efficient in-place sorting algorithm, which usually beats all other sorting algorithms in terms of performance. Due to its high performance, it is used in several standard library sort functions.
Given an integer array, find a triplet having the maximum product.
Given an integer array between 0 and 9, find two numbers with maximum sum formed using all the array digits. The difference in the number of digits of the two numbers should be ± 1.
Given a collection of n items, each of which has a non-negative integer key whose maximum value is at most k, effectively sort it using the counting sort algorithm.
Given an array with many duplicated elements, write an algorithm to efficiently sort it in linear time, where the order of equal elements doesn’t matter.
Quicksort exhibits poor performance for inputs that contain many repeated elements. The problem is visible when all the input elements are equal. In this post, we will implement Quicksort efficiently for inputs containing many repeated elements.
This post will discuss how to find permutations of a string using iteration. The implementation should be able to handle strings with duplicate characters and don’t repeat the permutations.
Lexicographic sorting: Given a set of strings, print them in lexicographic order (dictionary/alphabetical order).