What is the most efficient way to sort a list, [0,0,1,0,1,1,0] whose elements are only 0 & 1, without using any builtin sort() or sorted() or count() function. O(n) or less than that
You have only two values, so you know in advance the precise structure of the output: it will be divided into two regions of varying lengths.
Sort a list efficiently which contains only 0 and 1 without using any builtin python sort function?