leetcode
leetcode copied to clipboard
Bug Report for majority-element
Bug Report for https://neetcode.io/problems/majority-element
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Test case broken This code passes all testes func majorityElement(nums []int) int { mv := nums[0] mc := 1
for _, v := range nums {
if mv != v {
mc--
if mc <=0 {
mv = v
}
} else {
mc++
}
}
return mv
}