## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Remove Bad elements CodeChef Solution

## Problem

Chef has an array $A$ of length $N$.

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 $T$, 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 $N$ —the length of Array $A$.
• Next line contains $N$ space-separated integers $A_1, A_2, A_3, \dots, A_N$ - denoting the array $A$.

### Output Format

For each test case, output the minimum number of operations required to make all the elements same.

### Explanation:

Test case $1$: All the elements are already same. Thus we need to perform zero operations.

Test case $2$: We remove the elements $A_1, A_2,$ and $A_4$ using three operations. The array becomes $[2, 2, 2]$ where all elements are same.

Test case $3$: We remove the elements $A_1$ and $A_3$ using two operations. The array becomes $[2, 2]$ where all elements are same.

Test case $4$: We remove the elements $A_1, A_2, A_3,$ and $A_4$ using four operations. The array becomes $$.