mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-06 09:23:19 +08:00
fix 169: clean up redundant code
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user