What if there is some float number like 0.5? The question itself doesn't point this out, but I didn't find any float number in the test cases.
Yes, I think so. Otherwise, O(n) solution will not work.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.