/**
 * This function takes two lists as input and finds the intersection of the elements present in both lists.
 *
 * @param list1 A list of elements (can contain duplicates)
 * @param list2 A list of elements (can contain duplicates)
 * @return A list containing the intersection of elements from list1 and list2.
 */
fun intersectionOfLists(list1: List<Any>, list2: List<Any>): List<Any> {

    // Initialize an empty list to store the intersection of elements
    val intersectionList = mutableListOf<Any>()

    // Loop through each element in list1
    for (element in list1) {
        // Check if the element is present in list2
        if (element in list2) {
            // Check if the element is already added to the intersection list (to handle duplicates)
            if (element !in intersectionList) {
                // Add the element to the intersection list
                intersectionList.add(element)
            }
        }
    }

    return intersectionList
}
/**
 * This function takes two lists as input and finds the intersection of the elements present in both lists.
 *
 * @param list1 A list of elements (can contain duplicates)
 * @param list2 A list of elements (can contain duplicates)
 * @return A list containing the intersection of elements from list1 and list2.
 */
fun intersectionOfLists(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This function takes two lists as input and finds the intersection of the elements present in both lists.
 *
 * @param list1 A list of elements (can contain duplicates)
 * @param list2 A list of elements (can contain duplicates)
 * @return A list containing the intersection of elements from list1 and list2.
 */
fun intersectionOfLists(list1: List<Any>, list2: List<Any>): List<Any> {

    // Initialize an empty list to store the intersection of elements
    val intersectionList = mutableListOf<Any>()

    // Loop through each element in list1
    for (element in list1) {
        // Check if the element is present in list2
        if (element in list2) {
            // Check if the element is already added to the intersection list (to handle duplicates)
            if (element !in intersectionList) {
                // Add the element to the intersection list
                intersectionList.add(element)
            }
        }
    }

    return intersectionList
}