File tree Expand file tree Collapse file tree 1 file changed +12
-18
lines changed
Expand file tree Collapse file tree 1 file changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -8,26 +8,20 @@ public int maxMirror(int[] nums) {
88 int max = 0 ;
99
1010 for (int start = 0 ; start < nums .length ; start ++) {
11- int begin = nums .length - 1 ;
12-
13- while (begin >= 0 ) {
14- int finish = start + 1 ;
15- while (begin >= 0 && nums [begin ] != nums [start ])
16- begin --;
17-
18- int end = begin - 1 ;
19-
20- while (finish < nums .length && end >= 0 &&
21- nums [finish ] == nums [end ]) {
22- finish ++;
23- end --;
11+ for (int begin = nums .length - 1 ; begin >= 0 ; begin --) {
12+ int size = 0 ;
13+ int i = start ;
14+ int j = begin ;
15+
16+ while (i < nums .length && j >= 0 && nums [i ] == nums [j ]) {
17+ size ++;
18+ i ++;
19+ j --;
2420 }
25-
26- max = Math .max (max , finish - start );
27-
28- begin --;
21+
22+ max = Math .max (max , size );
2923 }
3024 }
31-
25+
3226 return max ;
3327}
You can’t perform that action at this time.
0 commit comments