/**
 * This function takes two arrays as arguments and returns the intersection of the arrays.
 *
 * @param array1 A list representing the first array.
 * @param array2 A list representing the second array.
 * @return A list containing all the elements that are common to both arrays.
 *
 * Example:
 * arrayIntersection(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 */
fun arrayIntersection(array1: List<Int>, array2: List<Int>): List<Int> {

    // Find the intersection of the arrays using filter function
    return array1.filter { it in array2 }
}
/**
 * This function takes two arrays as arguments and returns the intersection of the arrays.
 *
 * @param array1 A list representing the first array.
 * @param array2 A list representing the second array.
 * @return A list containing all the elements that are common to both arrays.
 *
 * Example:
 * arrayIntersection(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 */
fun arrayIntersection(array1: List<Int>, array2: List<Int>): List<Int> {
/**
 * This function takes two arrays as arguments and returns the intersection of the arrays.
 *
 * @param array1 A list representing the first array.
 * @param array2 A list representing the second array.
 * @return A list containing all the elements that are common to both arrays.
 *
 * Example:
 * arrayIntersection(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) // [3, 4]
 */
fun arrayIntersection(array1: List<Int>, array2: List<Int>): List<Int> {

    // Find the intersection of the arrays using filter function
    return array1.filter { it in array2 }
}