Check the number of occurrences in two Integer variables

I was recently asked to create a program that checks the number of occurrences within 2 separate integer variables.   I wrote a program using pseudo-code that uses the .Contains method.  It is possible to use the method if you import the System.Linq library.

The first way to check an integer array is Array.indexOf() method and the second way is using the .Contains() method.

Below is an example of how to do this:

There other way to check the integer array is to use the .Contains method.

Below is an example that use the .Contains method:

The third way to check is to use a Lambda expression. This is probably the most complex way to check but it definitely the coolest!

Leave a Reply

Your email address will not be published. Required fields are marked *