File tree 1 file changed +12
-14
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -58,23 +58,21 @@ public int findShortestSubArray(int[] nums) {
58
58
}
59
59
60
60
int findLength (int [] arr , int candidate ) {
61
- {
62
- int firstAppearance = Integer .MAX_VALUE ;
63
- for (int i = 0 ; i < arr .length ; i ++) {
64
- if (arr [i ] == candidate ) {
65
- firstAppearance = i ;
66
- break ;
67
- }
61
+ int firstAppearance = Integer .MAX_VALUE ;
62
+ for (int i = 0 ; i < arr .length ; i ++) {
63
+ if (arr [i ] == candidate ) {
64
+ firstAppearance = i ;
65
+ break ;
68
66
}
69
- int lastAppearance = arr . length - 1 ;
70
- for ( int i = arr .length - 1 ; i > firstAppearance ; i --) {
71
- if ( arr [ i ] == candidate ) {
72
- lastAppearance = i ;
73
- break ;
74
- }
67
+ }
68
+ int lastAppearance = arr .length - 1 ;
69
+ for ( int i = arr . length - 1 ; i > firstAppearance ; i -- ) {
70
+ if ( arr [ i ] == candidate ) {
71
+ lastAppearance = i ;
72
+ break ;
75
73
}
76
- return (lastAppearance - firstAppearance ) + 1 ;
77
74
}
75
+ return (lastAppearance - firstAppearance ) + 1 ;
78
76
}
79
77
}
80
78
}
You can’t perform that action at this time.
0 commit comments