File tree 2 files changed +8
-9
lines changed
s3486_longest_special_path_ii
2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 7
7
8
8
@ SuppressWarnings ("unused" )
9
9
public class Spreadsheet {
10
- private final Map <String , Integer > spreadsheet = new HashMap <>();
10
+ private final Map <String , Integer > data = new HashMap <>();
11
11
12
12
public Spreadsheet (int rows ) {}
13
13
14
14
public void setCell (String cell , int value ) {
15
- spreadsheet .put (cell , value );
15
+ data .put (cell , value );
16
16
}
17
17
18
18
public void resetCell (String cell ) {
19
- spreadsheet .put (cell , 0 );
19
+ data .put (cell , 0 );
20
20
}
21
21
22
22
public int getValue (String formula ) {
@@ -25,11 +25,11 @@ public int getValue(String formula) {
25
25
String right = formula .substring (index + 1 );
26
26
int x =
27
27
Character .isLetter (left .charAt (0 ))
28
- ? spreadsheet .getOrDefault (left , 0 )
28
+ ? data .getOrDefault (left , 0 )
29
29
: Integer .parseInt (left );
30
30
int y =
31
31
Character .isLetter (right .charAt (0 ))
32
- ? spreadsheet .getOrDefault (right , 0 )
32
+ ? data .getOrDefault (right , 0 )
33
33
: Integer .parseInt (right );
34
34
return x + y ;
35
35
}
Original file line number Diff line number Diff line change 6
6
import java .util .List ;
7
7
8
8
public class Solution {
9
- private int n ;
10
- private final int maxVal = 50000 ;
9
+ private final static int MAX_VAL = 50000 ;
11
10
private int dupCount ;
12
11
private int overCount ;
13
12
private long ansLength ;
@@ -19,7 +18,7 @@ public class Solution {
19
18
private int [] freq ;
20
19
21
20
public int [] longestSpecialPath (int [][] edges , int [] nums ) {
22
- this . n = nums .length ;
21
+ int n = nums .length ;
23
22
this .nums = nums ;
24
23
adj = new ArrayList <>();
25
24
for (int i = 0 ; i < n ; i ++) {
@@ -36,7 +35,7 @@ public int[] longestSpecialPath(int[][] edges, int[] nums) {
36
35
// Preallocate DFS chain arrays
37
36
path = new int [n ];
38
37
dist = new long [n ];
39
- freq = new int [maxVal + 1 ];
38
+ freq = new int [MAX_VAL + 1 ];
40
39
ansLength = 0 ;
41
40
ansNodes = Integer .MAX_VALUE ;
42
41
dupCount = 0 ;
You can’t perform that action at this time.
0 commit comments