/**
 * Given two sets of positive integers, find their intersection and return it as a new set.
 *
 * @param set1 A set of positive integers.
 * @param set2 Another set of positive integers.
 * @return A new set containing the intersection of set1 and set2.
 *
 * Example:
 * intersectionOfSets(setOf(1, 2, 3), setOf(2, 3, 4)) // returns setOf(2, 3)
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    val intersection = mutableSetOf<Int>()

    // Iterate through each element in set1
    for (num in set1) {
        // Check if the element is also present in set2
        if (num in set2) {
            intersection.add(num)
        }
    }

    return intersection
}
/**
 * Given two sets of positive integers, find their intersection and return it as a new set.
 *
 * @param set1 A set of positive integers.
 * @param set2 Another set of positive integers.
 * @return A new set containing the intersection of set1 and set2.
 *
 * Example:
 * intersectionOfSets(setOf(1, 2, 3), setOf(2, 3, 4)) // returns setOf(2, 3)
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * Given two sets of positive integers, find their intersection and return it as a new set.
 *
 * @param set1 A set of positive integers.
 * @param set2 Another set of positive integers.
 * @return A new set containing the intersection of set1 and set2.
 *
 * Example:
 * intersectionOfSets(setOf(1, 2, 3), setOf(2, 3, 4)) // returns setOf(2, 3)
 */
fun intersectionOfSets(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    val intersection = mutableSetOf<Int>()

    // Iterate through each element in set1
    for (num in set1) {
        // Check if the element is also present in set2
        if (num in set2) {
            intersection.add(num)
        }
    }

    return intersection
}