Bucket Sort Implementation
Bucket sort explained: scatter elements into buckets by range, sort each bucket, then concatenate. O(n) average for uniform data, in Python, Java and...
Arrays, Strings, Sliding Window, Two Pointers, Searching & Binary Search, Sorting, Linked List, Stack & Queue, Recursion & Backtracking, Trees, Heap / Priority Queue, Graphs, Dynamic Programming, Greedy, Bit Manipulation, Trie, Math & Number Theory, Design (LLD / OOP), SQL, System Design (HLD)
180 notes in 20 topics
Bucket sort explained: scatter elements into buckets by range, sort each bucket, then concatenate. O(n) average for uniform data, in Python, Java and...
Sort an Array (LeetCode 912): how to use built-in sorts and custom comparators in Python, Java and C++, including ascending, descending and key-based...
Merge Intervals (LeetCode 56): sort by start, then merge overlapping intervals in one pass. O(n log n), with Python, Java and C++ code.
Largest Number (LeetCode 179): sort numbers by a custom pairwise rule (a+b vs b+a) to form the biggest concatenation. O(n log n), Python/Java/C++.
Custom Sort String (LeetCode 791): sort one string by the character priority defined in another, using a rank map. O(n log n) or O(n), Python/Java/C++...
Sort Characters By Frequency (LeetCode 451): count characters, then sort by descending frequency and rebuild the string. O(n + k log k), Python/Java/C...
Kth Largest Element (LeetCode 215) via sorting: sort and index from the end in O(n log n), with a note on the O(n)-average quickselect alternative.
Relative Sort Array (LeetCode 1122): sort by the order defined in a second array, with the rest sorted ascending. O(n log n), Python/Java/C++.
Wiggle Sort II (LeetCode 324): strict nums[0] < nums[1] > nums[2]... via sorting and interleaving the two halves in reverse. O(n log n), Python/Java/C...
H-Index (LeetCode 274) via sorting: sort citations descending and find the largest i where citations[i] >= i+1. O(n log n), Python/Java/C++.
Meeting Rooms (LeetCode 252): sort meetings by start and check that none overlaps the previous one. O(n log n), Python/Java/C++.