TCS OA-15 2024
Problem Description
Given an integer array of size n, find all elements that appear more than one-third of the time.
Input Format
- The first line contains an integer N, representing the array's length.
- The second line contains N space-separated integers.
Output Format
Print all elements that appear more than one-third of the time in the array.
Constraints
- 1 ≤ N ≤ 10⁴
- -10⁹ <= arr[i] <= 10⁹
Example
Sample Input:
3
[3, 2, 3]
Sample Output:
3
Explanation:
- Total elements (n) = 3. We’re looking for numbers appearing more than 3/3 = 1 time.
- The number 3 appears twice, so the output is 3.