Company: QuickSell
Difficulty: medium
Majority Element Problem Description You are given an array arr of size n . You need to find the majority element in an array. A majority element in an array arr of size n is an element that appears strictly greater than n/2 times in the array. If no majority exists, return -1 . The function major_element() accepts the parameters array of integer arr having size n . Complete the function major_element() and return the value of maximum_times in the integer format. For Example: If the array arr is [2,2,3,4,2,3,2,2] of size 8 the number of occurrences of 2 is 5 which is more than (8/2=4) . Hence majority element will be 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: