isSubset<T> function

bool isSubset<T>(
  1. Set<T> a,
  2. Set<T> b
)

Checks if set a is a subset of set b.

Returns true if all elements of a are contained in b.

Time Complexity: O(n), where n is the size of a. Space Complexity: O(1)

Example:

bool result = isSubset({1, 2}, {1, 2, 3});
print(result); // Outputs: true

Implementation

bool isSubset<T>(Set<T> a, Set<T> b) => b.containsAll(a);