Skip to content

Commit 29b9304

Browse files
[N-0] refactor 697
1 parent 687135f commit 29b9304

File tree

1 file changed

+12
-14
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+12
-14
lines changed

src/main/java/com/fishercoder/solutions/_697.java

+12-14
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,21 @@ public int findShortestSubArray(int[] nums) {
5858
}
5959

6060
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;
6866
}
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;
7573
}
76-
return (lastAppearance - firstAppearance) + 1;
7774
}
75+
return (lastAppearance - firstAppearance) + 1;
7876
}
7977
}
8078
}

0 commit comments

Comments
 (0)