From 77cdd9817c80a0207d2601f75f8b08b9d957cb5f Mon Sep 17 00:00:00 2001 From: zzu <90972641+Zuhye@users.noreply.github.com> Date: Wed, 4 Nov 2026 23:46:55 +0900 Subject: [PATCH] Implement findDuplicates function to identify duplicates --- .../442. Find All Duplicates in an Array" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "leetcode3/\354\206\241\354\243\274\355\230\234/442. Find All Duplicates in an Array" diff --git "a/leetcode3/\354\206\241\354\243\274\355\230\234/442. Find All Duplicates in an Array" "b/leetcode3/\354\206\241\354\243\274\355\230\234/442. Find All Duplicates in an Array" new file mode 100644 index 00000000..8b121e72 --- /dev/null +++ "b/leetcode3/\354\206\241\354\243\274\355\230\234/442. Find All Duplicates in an Array" @@ -0,0 +1,16 @@ +class Solution: + def findDuplicates(self, nums: list[int]) -> list[int]: + ans = [] + numbers = {} + + for i in nums: + if i in numbers: + numbers[i] += 1 + else: + numbers[i] = 1 + + for i in numbers: + if numbers[i] ==2: + ans.append(i) + + return ans