[Solution] Card Removal CodeChef Solution | Solution CodeChef
Problem
You have cards placed in front of you on the table. The card has the number written on it.
In one move, you can remove any one card from the remaining cards on the table.
Find the minimum number of moves required so that all the cards remaining on the table have the same number written on them.
Input Format
- The first line 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 number of cards on the table.
- The second line of each test case contains space-separated integers where is the number written on the card.
Output Format
For each test case, output the minimum number of moves required so that all the cards remaining on the table have the same number written on them.
Explanation:
Test case : The minimum number of moves required such that all remaining cards have same values is :
- Move : Remove a card with number . Remaining cards are .
- Move : Remove a card with number . Remaining cards are .
- Move : Remove a card with number . Remaining cards are .
Test case : All cards have the same number initially. Thus, no moves are required.
Test case : The minimum number of moves required such that all remaining cards have same values is :
- Move : Remove a card with number . Remaining cards are .
- Move : Remove a card with number . Remaining cards are .
- Move : Remove a card with number . Remaining cards are .
- Move : Remove a card with number . Remaining cards are .
- Move : Remove a card with number . Remaining cards are .
No comments:
Post a Comment