Editorial for I Hate Ready to Program P3 - Test Case Limit Exceeded

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: Iaminnocent4298

Do not read this editorial unless you are stuck. Please attempt the problem before reading this page.

The trick to this question is to realize that the contents of the strings don't matter at all, and all that matters is the length of the strings.

Also, to solve this problem, it is necessary to always pick the strings with the shortest lengths. The proof of this greedy algorithm is left as an exercise to the reader.


There are no comments at the moment.