[Solution] Remove Bad elements CodeChef Solution
Problem
Chef has an array of length .
In one operation, Chef can remove any one element from the array.
Determine the minimum number of operations required to make all the elements same.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer —the length of Array .
- Next line contains space-separated integers - denoting the array .
Output Format
For each test case, output the minimum number of operations required to make all the elements same.
Explanation:
Test case : All the elements are already same. Thus we need to perform zero operations.
Test case : We remove the elements and using three operations. The array becomes where all elements are same.
Test case : We remove the elements and using two operations. The array becomes where all elements are same.
Test case : We remove the elements and using four operations. The array becomes .
No comments:
Post a Comment