/**
 * Given two sets, find and return the common elements using nested loops.
 *
 * @param set1 The first set of elements.
 * @param set2 The second set of elements.
 * @return A new set containing the common elements found in both sets.
 *
 * Example:
 * val set1 = setOf("apple", "banana", "orange")
 * val set2 = setOf("banana", "pear", "kiwi")
 * findCommonElements(set1, set2) // Output: ["banana"]
 */
fun findCommonElements(set1: Set<String>, set2: Set<String>): Set<String> {

    val commonElements = mutableSetOf<String>()

    // Iterate through each element in set1
    for (element1 in set1) {
        // Iterate through each element in set2
        for (element2 in set2) {
            // Check if the current element from set1 is equal to the current element from set2
            if (element1 == element2) {
                // Add the common element to the commonElements set
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}
/**
 * Given two sets, find and return the common elements using nested loops.
 *
 * @param set1 The first set of elements.
 * @param set2 The second set of elements.
 * @return A new set containing the common elements found in both sets.
 *
 * Example:
 * val set1 = setOf("apple", "banana", "orange")
 * val set2 = setOf("banana", "pear", "kiwi")
 * findCommonElements(set1, set2) // Output: ["banana"]
 */
fun findCommonElements(set1: Set<String>, set2: Set<String>): Set<String> {
/**
 * Given two sets, find and return the common elements using nested loops.
 *
 * @param set1 The first set of elements.
 * @param set2 The second set of elements.
 * @return A new set containing the common elements found in both sets.
 *
 * Example:
 * val set1 = setOf("apple", "banana", "orange")
 * val set2 = setOf("banana", "pear", "kiwi")
 * findCommonElements(set1, set2) // Output: ["banana"]
 */
fun findCommonElements(set1: Set<String>, set2: Set<String>): Set<String> {

    val commonElements = mutableSetOf<String>()

    // Iterate through each element in set1
    for (element1 in set1) {
        // Iterate through each element in set2
        for (element2 in set2) {
            // Check if the current element from set1 is equal to the current element from set2
            if (element1 == element2) {
                // Add the common element to the commonElements set
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}