Skip to content

Commit e496635

Browse files
committed
Adding Efficient Solution for Problem - 260 - Single Number III
1 parent 75de56e commit e496635

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
##==================================
2+
## Leetcode
3+
## Student: Vandit Jyotindra Gajjar
4+
## Year: 2020
5+
## Problem: 260
6+
## Problem Name: Single Number III
7+
##===================================
8+
#
9+
#Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.
10+
#
11+
#Example:
12+
#
13+
#Input: [1,2,1,3,2,5]
14+
#Output: [3,5]
15+
import collections as c #Importing collections module
16+
class Solution:
17+
def singleNumber(self, nums):
18+
return [item for item, count in c.Counter(nums).items() if count == 1] #Return the list containing excatly once element appearing in the array

0 commit comments

Comments
 (0)