Skip to content

Commit 1aeda7c

Browse files
committed
Sync LeetCode submission Runtime - 1 ms (86.85%), Memory - 19 MB (7.70%)
1 parent 898e2a8 commit 1aeda7c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

0169-majority-element/solution.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Approach 6 - Boyer-Moore Voting Algorithm
1+
# Approach 7 - Boyer-Moore Voting Algorithm
22

3-
# Time: O(N)
3+
# Time: O(n)
44
# Space: O(1)
55

66
class Solution:
77
def majorityElement(self, nums: List[int]) -> int:
88
count = 0
99
candidate = None
10-
10+
1111
for num in nums:
1212
if count == 0:
1313
candidate = num
1414
count += 1 if num == candidate else -1
15-
15+
1616
return candidate

0 commit comments

Comments
 (0)