logo CodeStepByStep logo

NumInCommon

Language/Type: C# Set collections
Related Links:

Write a method named NumInCommon that accepts two Lists of integers as parameters and returns the count of how many unique integers occur in both lists. For example, if two lists named l1 and l2 contains the values {3, 7, 3, -1, 2, 3, 7, 2, 15, 15} and {-5, 15, 2, -1, 7, 15, 36} respectively, your method should return 4 because the elements -1, 2, 7, and 15 occur in both lists. Use one or more sets as storage to help you solve this problem. Do not modify the lists passed in.

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.