169. Majority Element

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.

class Solution {
    public int majorityElement(int[] nums) {
        int count = 0 ;
        // means the number of target
        int target = 0 ;
        for(int i = 0 ;i

你可能感兴趣的:(169. Majority Element)