/**
 * Given two sets, this function finds the common elements between them using a while loop.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements between set1 and set2.
 */
fun findCommonElements(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    val commonElements = mutableSetOf<Any>()
    val set1Copy = set1.toMutableSet() // Creating a copy to avoid modifying the original set

    while (set1Copy.isNotEmpty()) {
        val element = set1Copy.first()
        set1Copy.remove(element)
        if (element in set2) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two sets, this function finds the common elements between them using a while loop.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements between set1 and set2.
 */
fun findCommonElements(set1: Set<Any>, set2: Set<Any>): Set<Any> {
/**
 * Given two sets, this function finds the common elements between them using a while loop.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements between set1 and set2.
 */
fun findCommonElements(set1: Set<Any>, set2: Set<Any>): Set<Any> {

    val commonElements = mutableSetOf<Any>()
    val set1Copy = set1.toMutableSet() // Creating a copy to avoid modifying the original set

    while (set1Copy.isNotEmpty()) {
        val element = set1Copy.first()
        set1Copy.remove(element)
        if (element in set2) {
            commonElements.add(element)
        }
    }

    return commonElements
}