/**
 * This function takes two lists as input and returns the intersection of the two lists. The intersection includes
 * only the elements that are common to both lists.
 *
 * @param firstList the first list
 * @param secondList the second list
 * @return A new list containing the common elements between the two input lists.
 */
fun intersectionOfLists(firstList: List<Any>, secondList: List<Any>): List<Any> {

    // Create a set to store unique elements of the first list
    val uniqueElemFirst = firstList.toSet()

    // Create a set to store the common elements between both lists
    val intersectionSet = mutableSetOf<Any>()

    // Check if an element from the second list is also present in the set of unique elements from the first list
    for (element in secondList) {
        if (element in uniqueElemFirst) {
            intersectionSet.add(element)
        }
    }

    // Convert the set of common elements to a list and return it
    return intersectionSet.toList()
}
/**
 * This function takes two lists as input and returns the intersection of the two lists. The intersection includes
 * only the elements that are common to both lists.
 *
 * @param firstList the first list
 * @param secondList the second list
 * @return A new list containing the common elements between the two input lists.
 */
fun intersectionOfLists(firstList: List<Any>, secondList: List<Any>): List<Any> {
/**
 * This function takes two lists as input and returns the intersection of the two lists. The intersection includes
 * only the elements that are common to both lists.
 *
 * @param firstList the first list
 * @param secondList the second list
 * @return A new list containing the common elements between the two input lists.
 */
fun intersectionOfLists(firstList: List<Any>, secondList: List<Any>): List<Any> {

    // Create a set to store unique elements of the first list
    val uniqueElemFirst = firstList.toSet()

    // Create a set to store the common elements between both lists
    val intersectionSet = mutableSetOf<Any>()

    // Check if an element from the second list is also present in the set of unique elements from the first list
    for (element in secondList) {
        if (element in uniqueElemFirst) {
            intersectionSet.add(element)
        }
    }

    // Convert the set of common elements to a list and return it
    return intersectionSet.toList()
}