1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
monotonic-array.cpp 378 Bytes
Copy Edit Raw Blame History
kamyu authored 7 years ago . Update monotonic-array.cpp
// Time: O(n)
// Space: O(1)
class Solution {
public:
bool isMonotonic(vector<int>& A) {
bool inc = false, dec = false;
for (int i = 0; i + 1 < A.size(); ++i) {
if (A[i] < A[i + 1]) {
inc = true;
} else if (A[i] > A[i + 1]) {
dec = true;
}
}
return !inc || !dec;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search