File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
s3486_longest_special_path_ii Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 77
88@ SuppressWarnings ("unused" )
99public class Spreadsheet {
10- private final Map <String , Integer > spreadsheet = new HashMap <>();
10+ private final Map <String , Integer > data = new HashMap <>();
1111
1212 public Spreadsheet (int rows ) {}
1313
1414 public void setCell (String cell , int value ) {
15- spreadsheet .put (cell , value );
15+ data .put (cell , value );
1616 }
1717
1818 public void resetCell (String cell ) {
19- spreadsheet .put (cell , 0 );
19+ data .put (cell , 0 );
2020 }
2121
2222 public int getValue (String formula ) {
@@ -25,11 +25,11 @@ public int getValue(String formula) {
2525 String right = formula .substring (index + 1 );
2626 int x =
2727 Character .isLetter (left .charAt (0 ))
28- ? spreadsheet .getOrDefault (left , 0 )
28+ ? data .getOrDefault (left , 0 )
2929 : Integer .parseInt (left );
3030 int y =
3131 Character .isLetter (right .charAt (0 ))
32- ? spreadsheet .getOrDefault (right , 0 )
32+ ? data .getOrDefault (right , 0 )
3333 : Integer .parseInt (right );
3434 return x + y ;
3535 }
Original file line number Diff line number Diff line change 66import java .util .List ;
77
88public class Solution {
9- private int n ;
10- private final int maxVal = 50000 ;
9+ private final static int MAX_VAL = 50000 ;
1110 private int dupCount ;
1211 private int overCount ;
1312 private long ansLength ;
@@ -19,7 +18,7 @@ public class Solution {
1918 private int [] freq ;
2019
2120 public int [] longestSpecialPath (int [][] edges , int [] nums ) {
22- this . n = nums .length ;
21+ int n = nums .length ;
2322 this .nums = nums ;
2423 adj = new ArrayList <>();
2524 for (int i = 0 ; i < n ; i ++) {
@@ -36,7 +35,7 @@ public int[] longestSpecialPath(int[][] edges, int[] nums) {
3635 // Preallocate DFS chain arrays
3736 path = new int [n ];
3837 dist = new long [n ];
39- freq = new int [maxVal + 1 ];
38+ freq = new int [MAX_VAL + 1 ];
4039 ansLength = 0 ;
4140 ansNodes = Integer .MAX_VALUE ;
4241 dupCount = 0 ;
You can’t perform that action at this time.
0 commit comments