File tree Expand file tree Collapse file tree 1 file changed +28
-27
lines changed
dsa-solutions/lc-solutions/0100-0199 Expand file tree Collapse file tree 1 file changed +28
-27
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,31 @@ First declare an empty hashmap then we store the each element and it's frequenci
55
55
#### Code in Different Languages
56
56
57
57
<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>
58
79
<TabItem value="Java" label="Java">
59
80
<SolutionAuthor name="@ImmidiSivani"/>
60
- ```java
81
+
82
+ ```Java
61
83
class Solution {
62
84
public int singleNumber(int[] nums) {
63
85
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
74
96
}
75
97
return a;
76
98
99
+ }
77
100
}
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>
103
104
104
105
#### Complexity Analysis
105
106
@@ -111,4 +112,4 @@ class Solution:
111
112
- **LeetCode Problem:** [Single Number ii](https://leetcode.com/problems/single-number-ii/description/)
112
113
- **Solution Link:** [Single Number ii on LeetCode](https://leetcode.com/problems/single-number-ii/post-solution/?submissionId=1273177780)
113
114
- **Authors Leetcode Profile:** [SivaniImmidi](https://leetcode.com/u/SivaniImmidi/)
114
- ```
115
+
You can’t perform that action at this time.
0 commit comments