[Solution] Dominant Element CodeChef Solution
Problem
You are given an array of length . An element is said to be dominant if the frequency of in is strictly greater than the frequency of any other element in the .
For example, if then is a dominant element since its frequency is higher than the frequency of any other element in .
Find if there exists any dominant element in .
Input Format
- The first line of input contains a single integer — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer — the size of the array .
- The second line of each test case contains space-separated integers denoting the array .
👇👇👇👇👇
Output Format
For each test case, output YES if there exists any dominant element in . Otherwise, output NO.
You may print each character of YES and NO in uppercase or lowercase (for example, yes, yEs, Yes will be considered identical).
Explanation:
Test case : is the dominant element.
Test case : There does not exist any dominant element.
Test case : is the dominant element.
No comments:
Post a Comment