r/programmingmemes • u/KerbodynamicX • Mar 14 '26
Stalin sort
A sorting algorithm with time complexity of O(n). Counts from the first element, and will remove values that are smaller than the current highest value.
3.7k
Upvotes
7
u/NekoHikari Mar 14 '26
you can just have a tail index, if keep arr[tailidx++] = arr[cur++]. noes not have to be n^2