fix 169: clean up redundant code

This commit is contained in:
novahe
2021-04-27 21:14:09 +08:00
parent 263ca6e3b7
commit 2d5005a24a

View File

@ -6,12 +6,11 @@ func majorityElement(nums []int) int {
for i := 0; i < len(nums); i++ {
if count == 0 {
res, count = nums[i], 1
}
if nums[i] == res {
count++
} else {
if nums[i] == res {
count++
} else {
count--
}
count--
}
}
return res