/**
 * Given two arrays, find the common elements between them.
 *
 * @param arr1 The first array.
 * @param arr2 The second array.
 * @return A list containing the common elements found in both arrays.
 */
fun findCommonElements(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    
    // Convert the arrays to sets for easier intersection
    val set1 = arr1.toSet()
    val set2 = arr2.toSet()
    
    // Find the common elements between the sets
    commonElements.addAll(set1.intersect(set2))
    
    return commonElements
}
/**
 * Given two arrays, find the common elements between them.
 *
 * @param arr1 The first array.
 * @param arr2 The second array.
 * @return A list containing the common elements found in both arrays.
 */
fun findCommonElements(arr1: List<Int>, arr2: List<Int>): List<Int> {
/**
 * Given two arrays, find the common elements between them.
 *
 * @param arr1 The first array.
 * @param arr2 The second array.
 * @return A list containing the common elements found in both arrays.
 */
fun findCommonElements(arr1: List<Int>, arr2: List<Int>): List<Int> {

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