Advertisement
Iam_Sandeep

283.Move Zeroes To end Two Pointer

Jun 29th, 2022
742
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution:
  2.     def moveZeroes(self, nums: List[int]) -> None:
  3.         l=r=0
  4.         n=len(nums)
  5.         while r<n:
  6.             if  nums[r]:
  7.                 nums[l],nums[r]=nums[r],nums[l]
  8.                 r+=1
  9.                 l+=1
  10.             else:
  11.                 r+=1
  12.         return nums
  13.                
  14.    
Advertisement
RAW Paste Data Copied
Advertisement