BSONG Editorial

PROBLEM LINK:

Practice

Contest

Author: Chandan Boruah

Tester: Chandan Boruah

Editorialist: Chandan Boruah

DIFFICULTY:

EASY

PREREQUISITES:

Brute Force

PROBLEM:

Given two types of notes, what is the minimum number of notes to change to make all notes similar.

QUICK EXPLANATION:

Print the number of notes that is smaller or equal to the other in count.

EXPLANATION:

All the notes of one type needs to be changed to the other type. So, the minimum number of notes needed to be changed would be equal to the one lesser in count.

AUTHOR’S SOLUTION

using System;
class some
{
	public static void Main()
	{
		int n=int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++)
		{
			int t=int.Parse(Console.ReadLine());
			string[]ss=Console.ReadLine().Split();
			int a=0;int b=0;
			foreach(string tt in ss)
			{
				if(tt.EndsWith("#"))
					a++;
				else b++;
			}
			Console.WriteLine(Math.Min(a,b));
		}
	}
}