logo Practice-It logo

containsAll

Language/Type: Java Sets and Maps
Author: Marty Stepp (on 2020/10/22)

Write a method containsAll that takes two sets of integers as parameters and that returns true if the first set contains all of the values of the second set and that returns false otherwise. For example, if the two sets are:

s1: [17, 16, 7, 10, 12, 13, 14]
s2: [7, 12, 13]

then the call containsAll(s1, s2) would return true while the call containsAll(s2, s1) would return false. You are implementing a two-argument alternative to the standard Set method called containsAll, so you are not allowed to call that method to solve this problem. You are also not allowed to construct any structured objects to solve the problem (no set, list, stack, queue, string, etc). Your method should not change either set passed as a parameter.

Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.