It wouldn't matter, but also if you have enough buckets to put the balls in if it was zero you'd put every ball in the same bucket which wouldn't make sense. You can always put the balls in different buckets and the minimum space between buckets is 1.
In Java, Arrays.sort() is implemented using a variant of the Quick Sort algorithm which has a space complexity of O(logn) for sorting
Gotcha, I think in Python its also not O(1) for sort but most people write it that way.
i don't understand why the left position has to be 1 and not 0?
it doesn't matter if it's 0 or 1, we are binary searching the gap not the array index
It wouldn't matter, but also if you have enough buckets to put the balls in if it was zero you'd put every ball in the same bucket which wouldn't make sense. You can always put the balls in different buckets and the minimum space between buckets is 1.
Cool thumbnail!!