1493. Longest Subarray of 1's After Deleting One Element - Day 5/31 Leetcode July 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
Рекомендации по теме
Комментарии
Автор

Were you able to delete the right element?

Algorithmist
Автор

looks much cleaner than a sliding window approach. do you think all questions can be solved using this methodology vs sliding window?

rosendo
Автор

I found a super clean solution, however, I can't really understand it, can someone explain it:
def longestSubarray(nums):
count = l = 0

for r in nums:
if not r:
count += 1
if count > 1:
if not nums[l]:
count -= 1
l += 1

return len(nums)-l-1

th
join shbcf.ru