GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.hackerrank.com — Java 1D Array (Part 2) | HackerRank We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies. 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. Function Description Complete the canWin function in the editor below. canWin has the following parameters:
Returns
Input Format The first line contains an integer, , denoting the number of queries (i.e., function calls).
Constraints
Sample Input STDIN Function ----- -------- 4 q = 4 (number of queries) 5 3 game[] size n = 5, leap = 3 (first query) 0 0 0 0 0 game = [0, 0, 0, 0, 0] 6 5 game[] size n = 6, leap = 5 (second query) 0 0 0 1 1 1 . . . 6 3 0 0 1 1 1 0 3 1 0 1 0 Sample Output Explanation We perform the following queries:
Cookie support is required to access HackerRankSeems like cookies are disabled on this browser, please enable them to open this website |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |