Problem example: Input: nums = [0,0,1,1,1,2,2,3,3,4] Output: 5, nums = [0,1,2,3,4,,,,,_] Explanation: Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively. It does not matter what you leave beyond the returned k (hence they are underscores).
My code:
class Solution(object):
def removeDuplicates(self, nums):
count = 0
array = []
for i in nums:
if i not in array:
array.append(i)
count+=1
nums = array
return count
My count function returns the amount of characters in the final list which is to be expected and my nums array is changed to not have duplicates. yet it still says that my nums is unchanged such as in this example: enter image description here
Although if i run a print function before my return, it outputs the correct nums array as shown here: enter image description here