/**
 * Given two lists, find the common elements and return them as a set.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return Set containing the common elements found.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6))  // Returns setOf(3, 4)
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("banana", "kiwi", "grape"))  // Returns setOf("banana")
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): Set<Any> {

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

    // Iterate over the elements of the first list
    for (element1 in list1) {
        // Iterate over the elements of the second list
        for (element2 in list2) {
            // Check if the elements are identical
            if (element1 == element2) {
                // Add the common element to the set
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}
/**
 * Given two lists, find the common elements and return them as a set.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return Set containing the common elements found.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6))  // Returns setOf(3, 4)
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("banana", "kiwi", "grape"))  // Returns setOf("banana")
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): Set<Any> {
/**
 * Given two lists, find the common elements and return them as a set.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return Set containing the common elements found.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6))  // Returns setOf(3, 4)
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("banana", "kiwi", "grape"))  // Returns setOf("banana")
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): Set<Any> {

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

    // Iterate over the elements of the first list
    for (element1 in list1) {
        // Iterate over the elements of the second list
        for (element2 in list2) {
            // Check if the elements are identical
            if (element1 == element2) {
                // Add the common element to the set
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}