aboutsummaryrefslogtreecommitdiff
path: root/non_decreasing_array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'non_decreasing_array.cpp')
-rw-r--r--non_decreasing_array.cpp27
1 files changed, 0 insertions, 27 deletions
diff --git a/non_decreasing_array.cpp b/non_decreasing_array.cpp
deleted file mode 100644
index 6ea4280..0000000
--- a/non_decreasing_array.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- bool checkPossibility(vector<int> &nums) {
- for (int i = 0; i < nums.size() - 1; i++) {
- if (nums[i] > nums[i + 1]) {
- if (i - 1 >= 0 && nums[i - 1] > nums[i + 1])
- nums[i + 1] = nums[i];
- else
- nums[i] = nums[i + 1];
- break;
- }
- }
- for (int i = 0; i < nums.size() - 1; i++) {
- if (nums[i] > nums[i + 1])
- return false;
- }
- return true;
- }
-};
-
-int main() {
- Solution obj;
- vector<int> nums = {4, 2, 3};
- cout << obj.checkPossibility(nums);
-}