/**
 * Given two sets, remove all elements from set1 that are also present in set2.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return The modified set1 after removing the intersection elements.
 *
 * Example:
 * val set1 = mutableSetOf(1, 2, 3, 4, 5)
 * val set2 = setOf(4, 5, 6, 7, 8)
 * removeIntersection(set1, set2) // Output: [1, 2, 3]
 */
fun removeIntersection(set1: MutableSet<Int>, set2: Set<Int>): MutableSet<Int> {

    val iterator = set1.iterator()
    while (iterator.hasNext()) {
        val elem = iterator.next()
        if (elem in set2) {
            iterator.remove()
        }
    }
    return set1
}
/**
 * Given two sets, remove all elements from set1 that are also present in set2.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return The modified set1 after removing the intersection elements.
 *
 * Example:
 * val set1 = mutableSetOf(1, 2, 3, 4, 5)
 * val set2 = setOf(4, 5, 6, 7, 8)
 * removeIntersection(set1, set2) // Output: [1, 2, 3]
 */
fun removeIntersection(set1: MutableSet<Int>, set2: Set<Int>): MutableSet<Int> {
/**
 * Given two sets, remove all elements from set1 that are also present in set2.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return The modified set1 after removing the intersection elements.
 *
 * Example:
 * val set1 = mutableSetOf(1, 2, 3, 4, 5)
 * val set2 = setOf(4, 5, 6, 7, 8)
 * removeIntersection(set1, set2) // Output: [1, 2, 3]
 */
fun removeIntersection(set1: MutableSet<Int>, set2: Set<Int>): MutableSet<Int> {

    val iterator = set1.iterator()
    while (iterator.hasNext()) {
        val elem = iterator.next()
        if (elem in set2) {
            iterator.remove()
        }
    }
    return set1
}