Given an integer array nums in which exactly two elements appear only once and all other elements appear twice.Find those two elements that appear only once.You can return answers in any order.
Advanced: Your algorithm should have linear time complexity.Can you do it using only constant space complexity?
Example 1:
Input: nums = [1,2,1,3,2,5]
Output: [3,5]
Explanation: [5, 3] is also a valid answer.
Example 2:
Input: nums = [-1,0]
Output: [-1,0]
Use a dictionary to store existing numbers and occurrences
class Solution:def singleNumber(self, nums: List[int]) -> List[int]:freq = collections.Counter(nums)res = []for k,v in freq.items():span>if v==1:res.append(k)return res