/**
 * Given two arrays arr1 and arr2, the function finds and returns the common elements between the two arrays.
 *
 * @param arr1 A list representing the first array.
 * @param arr2 A list representing the second array.
 * @return A list of common elements between arr1 and arr2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 11, 12), listOf(7, 8, 9)) // []
 */
fun findCommonElements(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (element in arr1) {
        if (element in arr2) {
            commonElements.add(element)
        }
    }
    return commonElements
}
/**
 * Given two arrays arr1 and arr2, the function finds and returns the common elements between the two arrays.
 *
 * @param arr1 A list representing the first array.
 * @param arr2 A list representing the second array.
 * @return A list of common elements between arr1 and arr2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 11, 12), listOf(7, 8, 9)) // []
 */
fun findCommonElements(arr1: List<Int>, arr2: List<Int>): List<Int> {
/**
 * Given two arrays arr1 and arr2, the function finds and returns the common elements between the two arrays.
 *
 * @param arr1 A list representing the first array.
 * @param arr2 A list representing the second array.
 * @return A list of common elements between arr1 and arr2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 11, 12), listOf(7, 8, 9)) // []
 */
fun findCommonElements(arr1: List<Int>, arr2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (element in arr1) {
        if (element in arr2) {
            commonElements.add(element)
        }
    }
    return commonElements
}