Hi,
I tried your solution with this input: people = { 80, 60, 60, 50, 40, 20, 20, 20 } limit = 80
The result was 4 but it should be 5.
I would change your while (x < y) to while (x <= y).
I'm just starting to play with leetcode and Maybe I misunderstood something.
Thanks J