Skip to content

Latest commit

 

History

History
29 lines (26 loc) · 765 Bytes

File metadata and controls

29 lines (26 loc) · 765 Bytes
 bool check(vector<int>& nums,int i,int j)
    {
        int n = nums.size();
        int prev = INT_MIN;
        for (int k = 0; k < n; k++) {
             if ((i <= k) && (k <= j)) continue;
            if (prev >= nums[k]) return false;
            prev = nums[k];
        }
        return true;
    }
    int incremovableSubarrayCount(vector<int>& nums) {
        int ans=0,n=nums.size();

        for(int i=0;i<n;i++)
        {
            for(int j=i;j<n;j++)
            {
                if(check(nums,i,j))
                    ans++;
            }
        }

        return ans;
    }