leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

Bug Report for majority-element

Open MadMeFed opened this issue 7 months ago • 0 comments

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

}

Image

MadMeFed avatar Apr 07 '26 17:04 MadMeFed