Solution, explanation, and complexity analysis for LeetCode 1552 in Java Problem Description: leetcode.com/problems/magneti... Code: github.com/AnatoliySokolov98/...
Пікірлер: 6
@rostyslavmochulskyi159Ай бұрын
In Java, Arrays.sort() is implemented using a variant of the Quick Sort algorithm which has a space complexity of O(logn) for sorting
@Alpha-CodeАй бұрын
Gotcha, I think in Python its also not O(1) for sort but most people write it that way.
@margin100pxАй бұрын
Cool thumbnail!!
@MehdiKhfifiАй бұрын
i don't understand why the left position has to be 1 and not 0?
@tzuilee588Ай бұрын
it doesn't matter if it's 0 or 1, we are binary searching the gap not the array index
@Alpha-CodeАй бұрын
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.