about | help | code help+videos | done | prefs |
Given a one-dimensional array of integers that represents a square matrix of integers, determine if there is a horizontal or vertical "path" from one end to the other end. Return true if at least one path exists, and return false if no such path exists. A "path" will consist of all zeros in a single horizontal row or vertical column. For example, pathExists({0,0,8,1,0,4,0,3,0}) returns false because it represents the matrix: 0 0 8, 1 0 4, 0 3 0 which does NOT have a horizontal or vertical "path" of zeros. However, if the 3 had been a 0, or if the 8 had been a zero, the method would return true since a path would exist in either of those cases. The array will contain at least one number. NOTE: The matrix representation is supposed to be a square 3 by 3 grid of numbers but I cannot make it appear correctly in JavaBat. bbvdStuffAdvanced2([0, 3, 1, 0]) → false bbvdStuffAdvanced2([0, 6, 0, 7]) → true bbvdStuffAdvanced2([0, 8, 5, 0, 1, 0, 0, 0, 0, 0, 0, 6, 0, 4, 0, 1]) → false ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 490
Copyright Nick Parlante 2017 - privacy