Leetcode 645 Solution
This article provides solution to leetcode question 645 (set-mismatch)
Access this page by simply typing in "lcs 645" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
class Solution: def findErrorNums(self, nums: List[int]) -> List[int]: m = collections.defaultdict(int) for n in nums: m[n] += 1 dup_ele = None miss_ele = None for i in range(1, len(nums) + 1): if m[i] == 0: miss_ele = i elif m[i] == 2: dup_ele = i return [dup_ele, miss_ele]