File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ class Solution :
2+ def containsDuplicate (self , nums : List [int ]) -> bool :
3+ sets = set (nums )
4+
5+ if len (nums ) != len (sets ):
6+ return True
7+ return False
8+
Original file line number Diff line number Diff line change 1+ class Solution (object ):
2+ def topKFrequent (self , nums , k ):
3+ count = {}
4+ result = []
5+
6+ for i in nums :
7+ if i not in count :
8+ count [i ] = 1
9+ else :
10+ count [i ] += 1
11+
12+ count = sorted (count .items (), key = lambda x : x [1 ], reverse = True )
13+
14+ return [item [0 ] for item in count [:k ]]
15+
Original file line number Diff line number Diff line change 1+ class Solution (object ):
2+ def twoSum (self , nums , target ):
3+ result = []
4+ for i in range (len (nums )- 1 ):
5+ for j in range (i + 1 , len (nums )):
6+ if (nums [i ] + nums [j ] == target ):
7+ result .append (i )
8+ result .append (j )
9+
10+ return result
You can’t perform that action at this time.
0 commit comments