#C6181. Minimum Teaching Rounds
Minimum Teaching Rounds
Minimum Teaching Rounds
You are given a company with (n) employees, where each employee is specialized in exactly one role: either coding or testing. The employees' skills are represented by a list of characters, where 'C' denotes a coder and 'T' denotes a tester.
In order to create a cross-functional team, the company may conduct teaching rounds. In each teaching round, one employee can be trained to become proficient in the other skill, effectively making that employee dual-skilled. However, to minimize training costs, the company chooses to only train those employees from the minority group. Consequently, the minimum number of teaching rounds required is equal to (\min(\text{number of coders}, \text{number of testers})).
For instance, if there are 5 employees with skills: C, T, C, C, T, then the number of coders is 3 and testers is 2. The optimal strategy is to train the 2 testers, resulting in 2 teaching rounds.
inputFormat
The first line contains an integer (n) ((1 \le n \le 10^5)), the number of employees. The second line contains (n) space-separated characters, each either 'C' or 'T', representing the skill of each employee.
outputFormat
Output a single integer representing the minimum number of teaching rounds required.## sample
5
C T C C T
2