arrow_back Back to Challenges

#169 Majority Element

Easy Acceptance 0%
description

Problem Description

Given an array `nums` of size `n`, return the majority element. The majority element is the element that appears more than `⌊n / 2⌋` times. You may assume that the majority element always exists in the array.

checklist Constraints

n == nums.length
1 <= n <= 5 * 10^4
-10^9 <= nums[i] <= 10^9

science Examples

Case #1

In: nums = [3,2,3]
Out: 3

Case #2

In: nums = [2,2,1,1,1,2,2]
Out: 2

Mastery Tags

Arrays Hash Table Sorting

Hiring Companies

Adobe Amazon Google
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude