/**
 * Given two lists, find and return the common elements between them.
 *
 * @param list1 The first list containing elements.
 * @param list2 The second list containing elements.
 * @return A list of common elements found in both input lists.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Convert the lists into sets for efficient intersection operation
    val set1 = list1.toSet()
    val set2 = list2.toSet()

    // Loop through each element in the first list
    for (element in set1) {
        // Check if the element is also present in the second list
        if (element in set2) {
            // Add the element to the commonElements list
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two lists, find and return the common elements between them.
 *
 * @param list1 The first list containing elements.
 * @param list2 The second list containing elements.
 * @return A list of common elements found in both input lists.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find and return the common elements between them.
 *
 * @param list1 The first list containing elements.
 * @param list2 The second list containing elements.
 * @return A list of common elements found in both input lists.
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Convert the lists into sets for efficient intersection operation
    val set1 = list1.toSet()
    val set2 = list2.toSet()

    // Loop through each element in the first list
    for (element in set1) {
        // Check if the element is also present in the second list
        if (element in set2) {
            // Add the element to the commonElements list
            commonElements.add(element)
        }
    }

    return commonElements
}