Logical Reasoning

Question 2

You have an array of n elements, and you have to find the majority element in that array.

  • Majority Element is the element that occurs more than (size/2) times in the given array

Input Format

  • First line will contain an integer size denoting the length of the array.
  • Second line will contain (size-1) separated integers, denoting the elements of the array

Output Format

  • If there is a majority element in an array, the output will be Majority element is : number
  • If there is no majority element in the array, the output will be Majority Element is not present in the list.
Zoho Coding Question

Code for the above Problem