1. How I sloved
Repeated numbers had to be moved backward from the list. When checking the numbers in the list, they were added to it if the numbers were not in ‘num_dict’. And the number was moved to the n-th on the list. The number of non-repeated numbers was then returned.
2. Code
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
num_dict = {}
cnt = 0
for i,e in enumerate(nums):
if e not in num_dict.keys():
num_dict[e] = i
nums[cnt] = e
cnt += 1
return cnt
3. Result
Runtime : 68 ms(99.07%), Memory usage : 16.5 MB(92.65%)
(Runtime can be different by a system even if it is a same code.)