← 返回 amazon 的题目列表Bird Collects Sticks
类型:online_judge
Given an integer array forest representing a forest and an integer bird representing the initial index of the bird. forest[i] denotes the length of a stick at position i, and if it is 0, it means there is no stick at position i. The initial position of the bird always has no stick. The bird starts moving right from the initial position, catches the first stick it finds, and returns it to the initial position. Then, it moves left, catches a stick, and returns it, repeating this process until it gathers a total length of sticks >= 100. Output the indexes of the sticks that are collected.
Example
Input: forest = [0,50,0,30,0,25], bird = 2
Output: [3, 1, 5]
Note: There will always be a stick in the right direction when the bird moves rightward.
Example
Input
0,50,0,30,0,25
2