about summary refs log tree commit diff stats
path: root/algorithms/java
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-11-03 21:17:12 +0530
committerAndinus <andinus@nand.sh>2021-11-03 21:17:12 +0530
commitc2d8da314510274dab62d0be92f8ae6138c01ad8 (patch)
tree5a8b6749a93aee309e07537a44a70b883382e57e /algorithms/java
parent7b812b8ef7456a491b667b52713cbef5dbc81bc6 (diff)
downloadfornax-c2d8da314510274dab62d0be92f8ae6138c01ad8.tar.gz
java/DFS: Keep variables in smallest scope
Diffstat (limited to 'algorithms/java')
-rw-r--r--algorithms/java/DFS.java9
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
ss='alt'>
ef7d834f ^









b301e0c0 ^
ef7d834f ^
b301e0c0 ^
ef7d834f ^


b301e0c0 ^
ef7d834f ^
805d58c6 ^



ef7d834f ^


b301e0c0 ^
ef7d834f ^
4a48bedc ^
e82dc626 ^
fe8bf967 ^

ef7d834f ^
b301e0c0 ^
ef7d834f ^
36365244 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100