标签:
/* * 169. Majority Element * 12.7 by Mingyang * 有时候简单到连开始的为空判断都不要 */ public int majorityElement(int[] num) { int major=num[0], count = 1; for(int i=1; i<num.length;i++){ if(count==0){ count++; major=num[i]; }else if(major==num[i]){ count++; }else count--; } return major; }
标签:
原文地址:http://www.cnblogs.com/zmyvszk/p/5560018.html