logo CodeStepByStep logo

LeastCommon

Language/Type: C# Dictionary collections
Related Links:

Write a method LeastCommon that accepts a Dictionary whose keys are strings and whose values are integers as a parameter and returns the integer value that occurs the fewest times in the dictionary. For example, if a dictionary named m contains {{"Alyssa", 22}, {"Char", 25}, {"Dan", 25}, {"Jeff", 20}, {"Kasey", 20}, {"Kim", 20}, {"Mogran", 25}, {"Ryan", 25}, {"Stef", 22}}, the call of LeastCommon(m) returns 22. If there is a tie, return the smaller integer value. If the dictionary is empty, throw an ArgumentException.

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.