Skip to content

Commit d9e81e7

Browse files
aQuaaQua
aQua
authored and
aQua
committed
169 简化代码后,程序依然比最快的满了63%
1 parent 0cb9c9c commit d9e81e7

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

Algorithms/0169.majority-element/majority-element.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,5 @@ func majorityElement(nums []int) int {
1212
m[n]++
1313
}
1414

15-
max, res := 0, 0
16-
for i, v := range m {
17-
if max < v {
18-
max = v
19-
res = i
20-
}
21-
}
22-
23-
return res
15+
return 0
2416
}

Algorithms/0169.majority-element/majority-element_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ func Test_Problem0169(t *testing.T) {
3535
1,
3636
},
3737
},
38-
38+
3939
question{
4040
para{
41-
[]int{1, 1, 2, 2},
41+
[]int{1, 1, 2, 2, 2},
4242
},
4343
ans{
44-
1,
44+
2,
4545
},
4646
},
47+
4748
question{
4849
para{
4950
[]int{1, 2, 2},

0 commit comments

Comments
 (0)