Editorial for Mock CCC '18 Contest 3 J3/S1 - A String Problem

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Author: xiaowuc1

This problem admitted a couple solutions. The easiest one to reason about is a brute force where you pick the characters you don't delete and delete the rest, and track the minimum count.

A more efficient solution would be to note that the two characters you don't want to delete are the two most frequent ones. You can accumulate these counts and report the sum of all but the two largest. Be wary of the case where the string only contains one distinct letter.


There are no comments at the moment.