* Returns a new set containing all elements from both sets. * @param otherSet - The set to union with * @returns A new set with all elements * @complexity Time O(n+m) | Space O(n+m)
(otherSet: MySet)
| 108 | * @complexity Time O(n+m) | Space O(n+m) |
| 109 | */ |
| 110 | union(otherSet: MySet): MySet { |
| 111 | const unionSet = new MySet(); |
| 112 | this.values().forEach(value => unionSet.add(value)); |
| 113 | otherSet.values().forEach(value => unionSet.add(value)); |
| 114 | return unionSet; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Returns a new set containing only elements present in both sets. |
no test coverage detected