1. How I sloved
I had to find the number that appeared only once. I made a dictionary, and if the number first came out, it was added to the dictionary. Otherwise the number was erased from the dictionary. Then the only number in the dictionary was returned.
2. Code
class Solution:
def singleNumber(self, nums: List[int]) -> int:
check_dict = {}
for e in nums:
if e not in check_dict:
check_dict[e] = 1
else:
del check_dict[e]
return list(check_dict.keys())[0]
3. Result
Runtime : 120 ms(50.75%), Memory usage : 16.3 MB(30.65%)
(Runtime can be different by a system even if it is a same code.)