As reported: Uber Backend Engineer online assessment (India, 2025) on CodeSignal, 70 minutes, 4 questions; question 2.
forest[i] is 0 for an empty spot or a positive number — the size of the stick lying there. A bird's nest is at index bird (an empty spot). The bird builds a nest of size at least 100:
- it flies right from the nest until it finds a stick, brings that stick back to the nest (the spot becomes empty and the nest grows by the stick's size);
- then it flies left from the nest to the nearest stick and brings it back;
- it keeps alternating right and left like this, and stops as soon as the nest size is
≥ 100.
Return the indices of the sticks it picked, in order.
Example 1
forest = [10, 50, 0, 100], bird = 2
Output: [3]
Example 2
forest = [25, 0, 50, 0, 0, 10, 40, 30], bird = 3
Output: [5, 2, 6] (10, then 50, then 40: 100)
Constraints: 1 ≤ forest.length ≤ 10^4; 0 ≤ forest[i] ≤ 100; forest[bird] = 0. Every search finds a stick before the nest reaches 100.
Code runner format: one JSON value per line: forest, bird. Implement pickSticks(forest, bird); the harness prints the list of indices.