Advertisement
Iam_Sandeep

283.Move Zeroes To end Two Pointer

Jun 29th, 2022
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement