Skip to content

Instantly share code, notes, and snippets.

@pirate-kiiiing
Last active July 16, 2023 00:18
def longestSubarray(self, nums: List[int]) -> int:
j = ans = zero = 0
for i in range(len(nums)):
if nums[i] == 0: zero += 1
while zero > 1:
if nums[j] == 0: zero -= 1
j += 1
ans = max(ans, i - j)
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment