Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9b6c804

Browse files
refactor 1055
1 parent f58055d commit 9b6c804

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.fishercoder.solutions;
22

3+
import java.util.stream.IntStream;
4+
35
/**
46
* 1055. Fixed Point
57
*
@@ -32,12 +34,7 @@
3234
public class _1055 {
3335
public static class Solution1 {
3436
public int fixedPoint(int[] A) {
35-
for (int i = 0; i < A.length; i++) {
36-
if (A[i] == i) {
37-
return i;
38-
}
39-
}
40-
return -1;
37+
return IntStream.range(0, A.length).filter(i -> A[i] == i).findFirst().orElse(-1);
4138
}
4239
}
4340
}

0 commit comments

Comments
 (0)