LeetCode-Algorithms-[Easy][摩爾投票法]面試題39. 數組中出現次數超過一半的數字

面試題39. 數組中出現次數超過一半的數字 面試 摩爾投票法詳解數組 public int majorityElement(int[] nums) { int num = nums[0]; int vote = 1; for (int i = 1; i < nums.length; ++i) { if (vote == 0) { num = nums[i]; }
相關文章
相關標籤/搜索