/**
 * Given two arrays, find the intersection of the elements between them.
 *
 * @param arr1 First array containing elements.
 * @param arr2 Second array containing elements.
 * @return A list containing the common elements between arr1 and arr2.
 */
fun findIntersection(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    
    // Convert arrays to sets for efficient intersection operation
    val set1 = arr1.toSet()
    val set2 = arr2.toSet()
    
    // Find common elements between sets
    val commonElements = set1.intersect(set2)
    
    // Convert set back to list
    intersection.addAll(commonElements)
    
    return intersection
}
/**
 * Given two arrays, find the intersection of the elements between them.
 *
 * @param arr1 First array containing elements.
 * @param arr2 Second array containing elements.
 * @return A list containing the common elements between arr1 and arr2.
 */
fun findIntersection(arr1: List<Int>, arr2: List<Int>): List<Int> {
/**
 * Given two arrays, find the intersection of the elements between them.
 *
 * @param arr1 First array containing elements.
 * @param arr2 Second array containing elements.
 * @return A list containing the common elements between arr1 and arr2.
 */
fun findIntersection(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    
    // Convert arrays to sets for efficient intersection operation
    val set1 = arr1.toSet()
    val set2 = arr2.toSet()
    
    // Find common elements between sets
    val commonElements = set1.intersect(set2)
    
    // Convert set back to list
    intersection.addAll(commonElements)
    
    return intersection
}