Company: QuickSell
Difficulty: medium
Majority Element Problem Description You are given an array arr of size n . Your task is to find its majority element. An array's majority element is a value that appears strictly more than n/2 times among its entries. If no such value exists, return -1 . The function major_element() takes the integer array arr of size n as its parameter. Complete major_element() so that it returns the value of maximum_times as an integer. For Example: If the array arr is [2,2,3,4,2,3,2,2] of size 8 , the value 2 occurs 5 times, which exceeds (8/2=4) . So the majority element here is 2 . Examples Example 1: Input: n=10 arr=[6,1,6,2,6,6,5,24,6,22] Output: maximum_times=-1 Example 2: Input: n=9 arr=[1,2,3,3,3,3,5,6,3] Output: