Hackerrank: Java 1D Array (Part 2)
Java 1D Array (Part 2) is one of the data structure questions in the Java problem set. It is a medium-level question but it is quite challenging because its solution may require you to use a depth-first search (DFS) algorithm. There are various ways to solve this problem, but my solution was to use the recursive DFS algorithm. Here we go. Here is the link to the problem: https://www.hackerrank.com/challenges/java-1d-array/problem The problem is about playing game on a set of arrays that consist of 0's and 1's only. You are standing at index 0 of an n-element array named game . From some index i , you can perform one of the following moves Move Backward: If cell i-1 exists and contains a 0, you can make a move back to the cell. Move Forward: - If cell i+1 exists and contains a 0, you can make a move forward to the cell. - If cell i+leap exists and contains a 0, you can jump to the cell i+leap . - If you are standing in cell n-1 , which is t...