Skip to content

Commit 3c5e94c

Browse files
committed
Time: 0 ms (100.00%) | Memory: 100.2 MB (90.84%) - LeetSync
1 parent 6b0e682 commit 3c5e94c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
bool isMonotonic(vector<int>& nums) {
4+
bool increasing = true ;
5+
bool decreasing = true ;
6+
for(int i = 1;i<nums.size();i++){
7+
if(nums[i] > nums[i - 1]){
8+
decreasing=false;
9+
}
10+
if(nums[i] < nums[i - 1]){
11+
increasing = false;
12+
}
13+
14+
}
15+
return increasing || decreasing;
16+
}
17+
};

0 commit comments

Comments
 (0)