/**
 * Given two lists, return a new list containing the intersection (common elements) of the two lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The new list containing the common elements.
 *
 * Example:
 * intersectionOfLists(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {

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

    // Iterate through elements of list1
    for (element1 in list1) {
        // Iterate through elements of list2
        for (element2 in list2) {
            // Check if the current elements are equal
            if (element1 == element2) {
                // Append the common element to the intersection list
                intersection.add(element1)
            }
        }
    }

    // Return the final list containing common elements
    return intersection
}
/**
 * Given two lists, return a new list containing the intersection (common elements) of the two lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The new list containing the common elements.
 *
 * Example:
 * intersectionOfLists(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, return a new list containing the intersection (common elements) of the two lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return The new list containing the common elements.
 *
 * Example:
 * intersectionOfLists(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 */
fun intersectionOfLists(list1: List<Int>, list2: List<Int>): List<Int> {

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

    // Iterate through elements of list1
    for (element1 in list1) {
        // Iterate through elements of list2
        for (element2 in list2) {
            // Check if the current elements are equal
            if (element1 == element2) {
                // Append the common element to the intersection list
                intersection.add(element1)
            }
        }
    }

    // Return the final list containing common elements
    return intersection
}