665. Non-decreasing Array - Day 25/30 Leetcode June Challenge

preview_player
Показать описание
Larry solves and analyzes this Leetcode problem as both an interviewer and an interviewee. This is a live recording of a real engineer solving a problem live - no cuts or edits!

#leetcode #coding #programming
Рекомендации по теме
Комментарии
Автор

Me when I am drunk: Try solve problem most stupid way.
Laryy when he drunk: Solve problem with most hardest way.

MrJerikoSalivan
Автор

non dp solution:
def checkPossibility(self, nums: List[int]) -> bool:
modified = False
for i in range(1, len(nums)):
if nums[i-1] > nums[i]:
if modified:
return False
modified = True
if i>1 and nums[i-2] > nums[i]:
nums[i] = nums[i-1]
return True

temptrue
join shbcf.ru