public class Solution {
public int majorityElement(int[] nums) {
int target=0,time=0;
for(int i:nums)
{
if(time==0)
{
target=i;
time=1;
}
else {
if(target==i) time++;
if(target!=i) time--;
}
}
return target;
}
}
leetcode: Majority Element
最新推荐文章于 2017-09-17 00:23:15 发布