Let's play a game on an array! You're standing at index of an -element array named . From some index (where ), you can perform one of the following moves:
In other words, you can move from index to index , , or as long as the destination index is a cell containing a . If the destination index is greater than , you win the game.
Given and , complete the function in the editor below so that it returns true if you can win the game (or false if you cannot).
The first line contains an integer, , denoting the number of queries (i.e., function calls).
The subsequent lines describe each query over two lines:
Return true if you can win the game; otherwise, return false.
0 0 0 0 0
0 0 0 1 1 1
0 0 1 1 1 0
0 1 0
We perform the following queries: