{"size": 535, "ext": "js", "max_stars_repo_path": "169. Majority Element/sol.js", "max_stars_repo_name": "Ashish1323/leetcodepractice", "max_stars_repo_stars_event_min_datetime": "2021-09-14T13:03:21.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T11:45:42.000Z", "max_issues_repo_path": "169. Majority Element/sol.js", "max_issues_repo_name": "Ashish1323/leetcodesolutions", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "169. Majority Element/sol.js", "max_forks_repo_name": "Ashish1323/leetcodesolutions", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.8148148148, "max_line_length": 38, "alphanum_fraction": 0.4224299065}
/**
 * @param {number[]} nums
 * @return {number}
 */
var majorityElement = function(nums) {
    var map=new Map()
    for(i=0;i<nums.length;i++){
        if(!map.has(nums[i])){
            map.set(nums[i],1)
        }
        else{
            var count=map.get(nums[i])
            count+=1
            map.set(nums[i],count)
        }
    }
    var ar=[...map.entries()]
    var max=0
    var m=0
    for(i=0;i<ar.length;i++){
        if(ar[i][1]>max){
            max=ar[i][1]
            m=ar[i][0]
        }
    }
    return m
};