标签:turn bsp ret 数组 public nbsp solution for result
1 class Solution { 2 public int majorityElement(int[] nums) { 3 4 int times=1; 5 int result = nums[0]; 6 for(int i=1;i<nums.length;i++) 7 { 8 if(times==0) 9 { 10 result = nums[i]; 11 times=1; 12 } 13 else if(result==nums[i]) 14 { 15 times++; 16 } 17 else 18 times--; 19 } 20 return result; 21 22 } 23 }
标签:turn bsp ret 数组 public nbsp solution for result
原文地址:https://www.cnblogs.com/wangyufeiaichiyu/p/11365495.html