/**
 * Returns the intersection of two arrays as a new array.
 *
 * @param arr1 The first input array.
 * @param arr2 The second input array.
 * @return The intersection of the two input arrays.
 *
 * Example:
 * intersectionOfArrays(intArrayOf(1, 2, 3, 4, 5), intArrayOf(4, 5, 6, 7, 8)) // [4, 5]
 * intersectionOfArrays(intArrayOf(7, 8, 9), intArrayOf(1, 2, 3)) // []
 */
fun intersectionOfArrays(arr1: IntArray, arr2: IntArray): List<Int> {

    val intersection = mutableListOf<Int>()

    for (num1 in arr1) {
        if (num1 in arr2) {
            intersection.add(num1)
        }
    }

    return intersection
}
/**
 * Returns the intersection of two arrays as a new array.
 *
 * @param arr1 The first input array.
 * @param arr2 The second input array.
 * @return The intersection of the two input arrays.
 *
 * Example:
 * intersectionOfArrays(intArrayOf(1, 2, 3, 4, 5), intArrayOf(4, 5, 6, 7, 8)) // [4, 5]
 * intersectionOfArrays(intArrayOf(7, 8, 9), intArrayOf(1, 2, 3)) // []
 */
fun intersectionOfArrays(arr1: IntArray, arr2: IntArray): List<Int> {
/**
 * Returns the intersection of two arrays as a new array.
 *
 * @param arr1 The first input array.
 * @param arr2 The second input array.
 * @return The intersection of the two input arrays.
 *
 * Example:
 * intersectionOfArrays(intArrayOf(1, 2, 3, 4, 5), intArrayOf(4, 5, 6, 7, 8)) // [4, 5]
 * intersectionOfArrays(intArrayOf(7, 8, 9), intArrayOf(1, 2, 3)) // []
 */
fun intersectionOfArrays(arr1: IntArray, arr2: IntArray): List<Int> {

    val intersection = mutableListOf<Int>()

    for (num1 in arr1) {
        if (num1 in arr2) {
            intersection.add(num1)
        }
    }

    return intersection
}