🦉 Collect Sticks
Problem Overview
- Given a forest array and a start index bird, output the indices of sticks the bird collects in order while alternating right then left until the total length is at least 100.
- Input: forest[i] is stick length (0 means no stick); bird is at an index with 0; Output: list of indices in pickup order.
- In each required direction, a stick is guaranteed to exist, so no empty searches or edge cases occur.
- This simulation problem models a bird collecting sticks and is a common coding interview task and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
