/**
 * This function takes two lists as input and finds the intersection of the two lists.
 * The intersection of two lists is a new list containing only the elements that are present in both lists.
 *
 * @param list1 The first input list
 * @param list2 The second input list
 * @return A new list containing the common elements present in both lists
 *
 * Example:
 * intersectionOfLists(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) // [4, 5]
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()  // Initialize an empty list to store the common elements

    for (element in list1) {  // Iterate over the elements in the first list
        if (element in list2) {  // Check if the element is also present in the second list
            commonElements.add(element)  // Add the common element to the commonElements list
        }
    }

    return commonElements
}
/**
 * This function takes two lists as input and finds the intersection of the two lists.
 * The intersection of two lists is a new list containing only the elements that are present in both lists.
 *
 * @param list1 The first input list
 * @param list2 The second input list
 * @return A new list containing the common elements present in both lists
 *
 * Example:
 * intersectionOfLists(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) // [4, 5]
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This function takes two lists as input and finds the intersection of the two lists.
 * The intersection of two lists is a new list containing only the elements that are present in both lists.
 *
 * @param list1 The first input list
 * @param list2 The second input list
 * @return A new list containing the common elements present in both lists
 *
 * Example:
 * intersectionOfLists(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) // [4, 5]
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()  // Initialize an empty list to store the common elements

    for (element in list1) {  // Iterate over the elements in the first list
        if (element in list2) {  // Check if the element is also present in the second list
            commonElements.add(element)  // Add the common element to the commonElements list
        }
    }

    return commonElements
}