/**
 * This exercise aims to test your understanding of null values and nested loops with sets.
 * Your task is to complete the code to find the common elements between two sets.
 *
 * @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>? {

    // Initialize an empty set to store the common elements
    val commonElements = mutableSetOf<Any>()

    // Check if both sets are present
    if (set1 == null || set2 == null) {
        return null
    }

    // Iterate over each element in set1
    for (element1 in set1) {
        // If an element is found in set2, add it to the commonElements set
        for (element2 in set2) {
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}
/**
 * This exercise aims to test your understanding of null values and nested loops with sets.
 * Your task is to complete the code to find the common elements between two sets.
 *
 * @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>? {
/**
 * This exercise aims to test your understanding of null values and nested loops with sets.
 * Your task is to complete the code to find the common elements between two sets.
 *
 * @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>? {

    // Initialize an empty set to store the common elements
    val commonElements = mutableSetOf<Any>()

    // Check if both sets are present
    if (set1 == null || set2 == null) {
        return null
    }

    // Iterate over each element in set1
    for (element1 in set1) {
        // If an element is found in set2, add it to the commonElements set
        for (element2 in set2) {
            if (element1 == element2) {
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}