Source Problem: https://leetcode.com/problems/single-number
This Solution Does not uses constant Space.
Solution:
class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
counter_dict = {}
for i in range(len(nums)):
if nums[i] in counter_dict:
counter_dict[nums[i]] = counter_dict[nums[i]] + 1
else:
counter_dict[nums[i]] = 1
#print(counter_dict)
found_key =None
for j ,y in counter_dict.items():
if y == 1:
found_key = j
break
return(found_key)
Solution Do not know its right way todo or not but i used solution like counts each elements occurrence using dict and then we travese through dict my using items and key ,value and match the target key once it found we update the variable found_key and just return it
Put Your Thought or Query Here