/**
 * Find the intersection of two lists and return a new list with the common elements.
 *
 * @param list1 First list of integers.
 * @param list2 Second list of integers.
 * @return New list containing the common elements.
 *
 * Example:
 * findIntersection(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 * findIntersection(listOf(-1, 0, 1, 2), listOf(0, 1, 2, 3)) // [0, 1, 2]
 */
fun findIntersection(list1: List<Int>, list2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    for (num in list1) {
        if (num in list2) {
            intersection.add(num)
        }
    }
    return intersection
}
/**
 * Find the intersection of two lists and return a new list with the common elements.
 *
 * @param list1 First list of integers.
 * @param list2 Second list of integers.
 * @return New list containing the common elements.
 *
 * Example:
 * findIntersection(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 * findIntersection(listOf(-1, 0, 1, 2), listOf(0, 1, 2, 3)) // [0, 1, 2]
 */
fun findIntersection(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Find the intersection of two lists and return a new list with the common elements.
 *
 * @param list1 First list of integers.
 * @param list2 Second list of integers.
 * @return New list containing the common elements.
 *
 * Example:
 * findIntersection(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 * findIntersection(listOf(-1, 0, 1, 2), listOf(0, 1, 2, 3)) // [0, 1, 2]
 */
fun findIntersection(list1: List<Int>, list2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    for (num in list1) {
        if (num in list2) {
            intersection.add(num)
        }
    }
    return intersection
}