forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_896.java
More file actions
28 lines (27 loc) · 712 Bytes
/
_896.java
File metadata and controls
28 lines (27 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.fishercoder.solutions;
public class _896 {
public static class Solution1 {
public boolean isMonotonic(int[] A) {
int i = 0;
for (; i < A.length - 1; i++) {
if (A[i] <= A[i + 1]) {
continue;
} else {
break;
}
}
if (i == A.length - 1) {
return true;
}
i = 0;
for (; i < A.length - 1; i++) {
if (A[i] >= A[i + 1]) {
continue;
} else {
break;
}
}
return i == A.length - 1;
}
}
}