Editorial for LCC '23 Contest 1 J3 - Candy Counting


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

Each candy type can be stored as a separate entry in a HashMap (Dictionary for python), with the name of the candy being the key, and the value being the number of the candy that Jayden got. After finishing populating the HashMap, one can simply loop through the HashMap and perform a modulo operation on each candy to obtain the remainder when divided with M. The answer is the sum of each candy's count after such an operation.

Time Complexity: O(N)


Comments

There are no comments at the moment.