diff options
author | Andinus <andinus@nand.sh> | 2021-11-03 21:17:12 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-11-03 21:17:12 +0530 |
commit | c2d8da314510274dab62d0be92f8ae6138c01ad8 (patch) | |
tree | 5a8b6749a93aee309e07537a44a70b883382e57e /algorithms/java | |
parent | 7b812b8ef7456a491b667b52713cbef5dbc81bc6 (diff) | |
download | fornax-c2d8da314510274dab62d0be92f8ae6138c01ad8.tar.gz |
java/DFS: Keep variables in smallest scope
Diffstat (limited to 'algorithms/java')
-rw-r--r-- | algorithms/java/DFS.java | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/algorithms/java/DFS.java b/algorithms/java/DFS.java index 61b2027..8d1e341 100644 --- a/algorithms/java/DFS.java +++ b/algorithms/java/DFS.java @@ -1,5 +1,5 @@ public class DFS { - private static final int[][] directions = new int[][]{ + static int[][] directions = new int[][]{ {+0, +1}, // Right. {+1, +0}, // Down. {+0, -1}, // Left. @@ -7,12 +7,9 @@ public class DFS { }; static void traverse(int x, int y, char[][] maze, boolean[][] visited) { - int curx; - int cury; - for (int i = 0; i < 4; i++) { - curx = x + directions[i][0]; - cury = y + directions[i][1]; + int curx = x + directions[i][0]; + int cury = y + directions[i][1]; // Out of bounds check. if (curx < 0 || cury < 0 |