/**
 * Finds the intersection of two sets.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A new set containing the common elements found in both sets.
 *
 * Examples:
 * val set1 = setOf(1, 2, 3, 4)
 * val set2 = setOf(3, 4, 5, 6)
 * intersectionOfSets(set1, set2) // Output: [3, 4]
 * val set3 = setOf(10, 20, 30, 40)
 * val set4 = setOf(30, 40, 50, 60)
 * intersectionOfSets(set3, set4) // Output: [30, 40]
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    val intersectionSet = mutableSetOf<Int>()
    for (element in set1) {
        if (element in set2) {
            intersectionSet.add(element)
        }
    }
    return intersectionSet
}
/**
 * Finds the intersection of two sets.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A new set containing the common elements found in both sets.
 *
 * Examples:
 * val set1 = setOf(1, 2, 3, 4)
 * val set2 = setOf(3, 4, 5, 6)
 * intersectionOfSets(set1, set2) // Output: [3, 4]
 * val set3 = setOf(10, 20, 30, 40)
 * val set4 = setOf(30, 40, 50, 60)
 * intersectionOfSets(set3, set4) // Output: [30, 40]
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * Finds the intersection of two sets.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A new set containing the common elements found in both sets.
 *
 * Examples:
 * val set1 = setOf(1, 2, 3, 4)
 * val set2 = setOf(3, 4, 5, 6)
 * intersectionOfSets(set1, set2) // Output: [3, 4]
 * val set3 = setOf(10, 20, 30, 40)
 * val set4 = setOf(30, 40, 50, 60)
 * intersectionOfSets(set3, set4) // Output: [30, 40]
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    val intersectionSet = mutableSetOf<Int>()
    for (element in set1) {
        if (element in set2) {
            intersectionSet.add(element)
        }
    }
    return intersectionSet
}