/**
 * This function finds the intersection of two arrays using indexing and loops.
 *
 * @param arr1 The first input array.
 * @param arr2 The second input array.
 * @return A new list containing the common elements found in both arrays.
 */
fun intersectArrays(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    for (i in arr1.indices) {
        for (j in arr2.indices) {
            if (arr1[i] == arr2[j]) {
                intersection.add(arr1[i])
            }
        }
    }

    return intersection
}
/**
 * This function finds the intersection of two arrays using indexing and loops.
 *
 * @param arr1 The first input array.
 * @param arr2 The second input array.
 * @return A new list containing the common elements found in both arrays.
 */
fun intersectArrays(arr1: List<Int>, arr2: List<Int>): List<Int> {
/**
 * This function finds the intersection of two arrays using indexing and loops.
 *
 * @param arr1 The first input array.
 * @param arr2 The second input array.
 * @return A new list containing the common elements found in both arrays.
 */
fun intersectArrays(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    for (i in arr1.indices) {
        for (j in arr2.indices) {
            if (arr1[i] == arr2[j]) {
                intersection.add(arr1[i])
            }
        }
    }

    return intersection
}