6
This commit is contained in:
17
solutions/lc1909.py
Normal file
17
solutions/lc1909.py
Normal file
@@ -0,0 +1,17 @@
|
||||
class Solution:
|
||||
def canBeIncreasing(self, nums: List[int]) -> bool:
|
||||
bad = 0
|
||||
for i in range(1, len(nums)):
|
||||
if nums[i] <= nums[i - 1]:
|
||||
bad += 1
|
||||
|
||||
if bad > 1:
|
||||
return False
|
||||
|
||||
l = i == 1 or nums[i] > nums[i - 2]
|
||||
r = i == len(nums) - 1 or nums[i + 1] > nums[i - 1]
|
||||
|
||||
if not l and not r:
|
||||
return False
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user