easy +10 pts

Subset of another set

Determine if every element of one set appears in another.

Write a function `is_subset(subset: set, superset: set) -> bool` that returns `True` if `subset` is a subset of `superset`, and `False` otherwise. A set A is a subset of set B if every element of A is also an element of B. The empty set is a subset of every set.

Constraints

The inputs are Python sets with hashable elements. Element counts can be large (up to 10^6), so use efficient set operations. The function should not modify the input sets.

Example

>>> is_subset({1, 2}, {1, 2, 3})
True
>>> is_subset({1, 4}, {1, 2, 3})
False
>>> is_subset(set(), {1, 2})
True
10 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Recall that Python sets support the `<=` operator for subset checking.
The empty set is a subset of every set.
A set is always a subset of itself.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.