/**
 * Given two sorted arrays, arr1 and arr2, find the intersection of the two arrays.
 *
 * @param arr1 A sorted list of integers
 * @param arr2 A sorted list of integers
 * @return A sorted list of integers representing the intersection of arr1 and arr2
 */
fun findIntersection(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    var i = 0
    var j = 0

    while (i < arr1.size && j < arr2.size) {
        when {
            arr1[i] < arr2[j] -> i++
            arr1[i] > arr2[j] -> j++
            else -> {
                intersection.add(arr1[i])
                i++
                j++
            }
        }
    }

    return intersection
}
/**
 * Given two sorted arrays, arr1 and arr2, find the intersection of the two arrays.
 *
 * @param arr1 A sorted list of integers
 * @param arr2 A sorted list of integers
 * @return A sorted list of integers representing the intersection of arr1 and arr2
 */
fun findIntersection(arr1: List<Int>, arr2: List<Int>): List<Int> {
/**
 * Given two sorted arrays, arr1 and arr2, find the intersection of the two arrays.
 *
 * @param arr1 A sorted list of integers
 * @param arr2 A sorted list of integers
 * @return A sorted list of integers representing the intersection of arr1 and arr2
 */
fun findIntersection(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    var i = 0
    var j = 0

    while (i < arr1.size && j < arr2.size) {
        when {
            arr1[i] < arr2[j] -> i++
            arr1[i] > arr2[j] -> j++
            else -> {
                intersection.add(arr1[i])
                i++
                j++
            }
        }
    }

    return intersection
}