Did I make a new copy of list?


  • -2
    J

    Hi, I am new to programming, could any one tell me whether I made a new list by using list.remove and list.append? Thank you!

    Here is my code:

    class Solution(object):
        def moveZeroes(self, nums):
            """
            :type nums: List[int]
            :rtype: void Do not return anything, modify nums in-place instead.
            """
            for i in nums:
                if i==0:
                    nums.remove(i)
                    nums.append(0)

  • 0

    @jianru New users please read the instructions to format your code properly.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.