Skip to content
CampusEduX

Find the Majority Element

Mediumjavapythonccppjavascript

Given an array of size N, find the element that appears more than N/2 times. You may assume a majority element always exists.

Input Format

The first line contains an integer N. The second line contains N space-separated integers.

Output Format

Print the majority element.

Related Problems

  • Rotate an Array by K Positions
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Maximum Subarray Sum
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Find a Subarray with Given Sum
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...