forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_941.java
29 lines (28 loc) · 819 Bytes
/
_941.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
25
26
27
28
29
package com.fishercoder.solutions;
public class _941 {
public static class Solution1 {
public boolean validMountainArray(int[] arr) {
int i = 0;
for (; i < arr.length - 1; i++) {
if (arr[i] < arr[i + 1]) {
continue;
} else if (arr[i] == arr[i + 1]) {
return false;
} else {
break;
}
}
if (i == 0 || i >= arr.length - 1) {
return false;
}
for (; i < arr.length - 1; i++) {
if (arr[i] > arr[i + 1]) {
continue;
} else {
return false;
}
}
return i == arr.length - 1;
}
}
}