
Problem
Analysis
Solution
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class : def checkPossibility(self, nums): """ :type nums: List[int] :rtype: bool """ pos = None for i in range(len(nums)-1): if nums[i] > nums[i+1]: if pos is not None: return False pos = i return (pos is None or pos==0 or pos==len(nums)-2 or nums[pos-1]<=nums[pos+1] or nums[pos]<=nums[pos+2])
|
Link
665. Non-decreasing Array
近期评论