We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d5d8524 commit 10e7464Copy full SHA for 10e7464
Find_Duplicate_Number/EfficientSolution.py
@@ -0,0 +1,23 @@
1
+##==================================
2
+## Leetcode
3
+## Student: Vandit Jyotindra Gajjar
4
+## Year: 2020
5
+## Problem: 287
6
+## Problem Name: Find the Duplicate Number
7
+##===================================
8
+#
9
+#Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive),
10
+#prove that at least one duplicate number must exist. Assume that there is only one duplicate number,
11
+#find the duplicate one.
12
13
+#Example 1:
14
15
+#Input: [1,3,4,2,2]
16
+#Output: 2
17
+#Example 2:
18
19
+#Input: [3,1,3,4,2]
20
+#Output: 3
21
+class Solution:
22
+ def findDuplicate(self, nums):
23
+ return "".join([str(key) for key, val in collections.Counter(nums).items() if val != 1]) #Return the duplicate number
0 commit comments