Skip to content

Commit 174e8aa

Browse files
committed
Merge pull request #95 from wilsoncao/master
Fix bug
2 parents 009085f + 0d45bbc commit 174e8aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

algorithms/cpp/majorityElement/majorityElement.II.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Solution {
3636
//the same algorithm as Majority Element I problem
3737
int majority1=0, majority2=0, cnt1=0, cnt2=0;
3838
for(auto item: nums) {
39-
if (cnt1 == 0) {
39+
if (cnt1 == 0 && majority2 != item ) {
4040
majority1 = item;
4141
cnt1 = 1;
4242
} else if (majority1 == item) {

0 commit comments

Comments
 (0)