Category: sorting
We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is …
Given an array of strings, group anagrams together. Example: Input: , Output: , , ] Note: All inputs will be in lowercase. The order of your output does not …
Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 The Merge sort performs …
nth_element is a partial sorting algorithm which can be invoked by including the header algorithm. It has following two forms: void nth_element(_RanIt _First, _RanIt _Nth, _RanIt _Last); void nth_element(_RanIt …
The selection sort, similar to insertion sort, is one of the simple sorting algorithm that has O(N^2) time complexity. The selection sorting algorithm is quadratic, thus not efficient when …