/**
 * Given two lists, list1 and list2, this function returns a new list containing only the elements that are present in both lists.
 *
 * @param list1 First input list.
 * @param list2 Second input list.
 * @return New list containing the common elements from both lists.
 */
fun intersectionOfLists(list1: List<Any>, list2: List<Any>): List<Any> {

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

    // Find the intersection of the two sets and convert it back to a list
    val intersectionList = set1.intersect(set2).toList()

    return intersectionList
}
/**
 * Given two lists, list1 and list2, this function returns a new list containing only the elements that are present in both lists.
 *
 * @param list1 First input list.
 * @param list2 Second input list.
 * @return New list containing the common elements from both lists.
 */
fun intersectionOfLists(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, list1 and list2, this function returns a new list containing only the elements that are present in both lists.
 *
 * @param list1 First input list.
 * @param list2 Second input list.
 * @return New list containing the common elements from both lists.
 */
fun intersectionOfLists(list1: List<Any>, list2: List<Any>): List<Any> {

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

    // Find the intersection of the two sets and convert it back to a list
    val intersectionList = set1.intersect(set2).toList()

    return intersectionList
}