Skip to content

Commit ec4aab4

Browse files
authored
create 0941 folder & cpp version
1 parent c0a1ec4 commit ec4aab4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
bool validMountainArray(vector<int>& A) {
4+
if (A.size() < 3)
5+
return false ;
6+
7+
A.push_back(A[0]) ;
8+
int lastIndex = A.size()-2 ;
9+
int p ;
10+
for (p = 0; A[p] < A[p+1]; ++p)
11+
;
12+
if (p == lastIndex || 0 == p)
13+
return false ;
14+
A[A.size()-1] = A[p] ;
15+
for (; A[p] > A[p+1]; ++p)
16+
;
17+
18+
return p == lastIndex ;
19+
}
20+
};

0 commit comments

Comments
 (0)