/**
 * Given two arrays, find all the common elements between them.
 *
 * @param arr1 The first array.
 * @param arr2 The second array.
 * @return A list containing the common elements.
 *
 * Example:
 * '``kotlin
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "cherry"), listOf("banana", "orange", "cherry")) // ["banana", "cherry"]
 * '``
 */
fun findCommonElements(arr1: List<Any>, arr2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    for (item1 in arr1) {
        for (item2 in arr2) {
            if (item1 == item2) {
                commonElements.add(item1)
            }
        }
    }
    return commonElements
}
/**
 * Given two arrays, find all the common elements between them.
 *
 * @param arr1 The first array.
 * @param arr2 The second array.
 * @return A list containing the common elements.
 *
 * Example:
 * '``kotlin
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "cherry"), listOf("banana", "orange", "cherry")) // ["banana", "cherry"]
 * '``
 */
fun findCommonElements(arr1: List<Any>, arr2: List<Any>): List<Any> {
/**
 * Given two arrays, find all the common elements between them.
 *
 * @param arr1 The first array.
 * @param arr2 The second array.
 * @return A list containing the common elements.
 *
 * Example:
 * '``kotlin
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "cherry"), listOf("banana", "orange", "cherry")) // ["banana", "cherry"]
 * '``
 */
fun findCommonElements(arr1: List<Any>, arr2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    for (item1 in arr1) {
        for (item2 in arr2) {
            if (item1 == item2) {
                commonElements.add(item1)
            }
        }
    }
    return commonElements
}