Submission Detail

45 / 45 test cases passed.
Status:

Accepted

Runtime: 140 ms
Memory Usage: 15.2 MB
Submitted: 4 days, 18 hours ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

100
110
120
130
140
150
160
170
180
1.0
2.0
3.0
4.0
5.0
python
You are here!
Your runtime beats 51.41 % of python submissions.
Runtime (ms)
Distribution (%)

100
110
120
130
140
150
160
170
180
2
4
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

13800
14000
14200
14400
14600
14800
15000
15200
15400
15600
5
10
15
20
25
30
python
You are here!
Your memory usage beats 26.34 % of python submissions.
Memory (KB)
Distribution (%)

13800
14000
14200
14400
14600
14800
15000
15200
15400
15600
10
20
30
Zoom area by dragging across this chart

Invite friends to challenge Majority Element


Submitted Code: 4 days, 18 hours ago

Language: python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Solution(object):
def majorityElement(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
elements = {}
for i in nums:
if i not in elements:
elements[i] = 1
else:
elements[i] += 1
print(elements)
majority_value = 0
majority_key = 0
for k,v in elements.items():
if (v > floor(len(nums)/2)):
if v > majority_value:
majority_key = k
majority_value = v
return majority_key
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX