-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
Copy path775.java
24 lines (23 loc) · 792 Bytes
/
775.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
__________________________________________________________________________________________________
sample 1 ms submission
class Solution {
public boolean isIdealPermutation(int[] A) {
for(int i = 0; i < A.length; i++){
if(A[i] - i < -1 || A[i] - i > 1){
return false;
}
}
return true;
}
}
__________________________________________________________________________________________________
sample 39756 kb submission
class Solution {
public boolean isIdealPermutation(int[] A) {
for (int i = 0; i < A.length; ++i) {
if (Math.abs(A[i] - i) > 1) return false;
}
return true;
}
}
__________________________________________________________________________________________________