Skip to content

Commit 1a1ac5e

Browse files
committed
Update 0137-Single-Number-II
1 parent 187502c commit 1a1ac5e

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

dsa-solutions/lc-solutions/0100-0199/0137-Single-Number-II

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,31 @@ First declare an empty hashmap then we store the each element and it's frequenci
5555
#### Code in Different Languages
5656

5757
<Tabs>
58+
59+
60+
<TabItem value="Python" label="Python" default>
61+
62+
<SolutionAuthor name="@ImmidiSivani"/>
63+
64+
```Python
65+
class Solution:
66+
def singleNumber(self, nums: List[int]) -> int:
67+
mp = {}
68+
for num in nums:
69+
if num in mp:
70+
mp[num] += 1
71+
else:
72+
mp[num] = 1
73+
74+
for num, c in mp.items():
75+
if c == 1:
76+
return num
77+
```
78+
</TabItem>
5879
<TabItem value="Java" label="Java">
5980
<SolutionAuthor name="@ImmidiSivani"/>
60-
```java
81+
82+
```Java
6183
class Solution {
6284
public int singleNumber(int[] nums) {
6385
Map<Integer,Integer> mp=new HashMap<>();
@@ -74,32 +96,11 @@ First declare an empty hashmap then we store the each element and it's frequenci
7496
}
7597
return a;
7698

99+
}
77100
}
78-
}
79-
80-
`````
81-
</TabItem>
82-
83-
<TabItem value="Python" label="Python">
84-
<SolutionAuthor name="@ImmidiSivani"/>
85-
86-
````python
87-
class Solution:
88-
def singleNumber(self, nums: List[int]) -> int:
89-
mp = {}
90-
for num in nums:
91-
if num in mp:
92-
mp[num] += 1
93-
else:
94-
mp[num] = 1
95-
96-
for num, c in mp.items():
97-
if c == 1:
98-
return num
99-
100-
`````
101-
102-
</TabItem>
101+
```
102+
</TabItem>
103+
</Tabs>
103104

104105
#### Complexity Analysis
105106

@@ -111,4 +112,4 @@ class Solution:
111112
- **LeetCode Problem:** [Single Number ii](https://leetcode.com/problems/single-number-ii/description/)
112113
- **Solution Link:** [Single Number ii on LeetCode](https://leetcode.com/problems/single-number-ii/post-solution/?submissionId=1273177780)
113114
- **Authors Leetcode Profile:** [SivaniImmidi](https://leetcode.com/u/SivaniImmidi/)
114-
```
115+

0 commit comments

Comments
 (0)