Posted on

Description

Submission

class Solution {
    bool increasing(vector<int>& nums) {
        for(int i = 1; i < nums.size(); ++i) {
            if(nums[i-1] >= nums[i]) return false;
        }
        return true;
    }
public:
    bool canBeIncreasing(vector<int>& nums) {
        if(increasing(nums)) return true;
        auto t1 = nums;
        auto t2 = nums;
        for(int i = 1; i < nums.size(); ++i) {
            if(nums[i] <= nums[i-1] ) {
                t1.erase(t1.begin() + i - 1);
                t2.erase(t2.begin() + i);
                break;
            }
        }
        return increasing(t1) || increasing(t2);
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *