May LeetCoding Challenge #Day6 #Majority Element #Java

    May LeetCoding Challenge[Day6] - 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. You may assume that the array is non-empty and the majority element always exist in the array. Input: [3,2,3] Output: 3 Input: [2,2,1,1,1,2,2] Output: 2 1. 알고리즘을 해결하기 위해서 생각한 방법 - 해당 문제는 배열이 주어질 때, 주어진 배열의 크기 n보다, 항상 [n/2] 보다 많은 수가 존재한다. - 처음 접근 방법은 Map을 사용했다. Map을 통해서 K..