/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first list of elements.
 * @param list2 The second list of elements.
 * @return A list of common elements between list1 and list2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("banana", "grape", "apple")) // ["banana", "apple"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    for (element in list1) {
        if (element in list2) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first list of elements.
 * @param list2 The second list of elements.
 * @return A list of common elements between list1 and list2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("banana", "grape", "apple")) // ["banana", "apple"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first list of elements.
 * @param list2 The second list of elements.
 * @return A list of common elements between list1 and list2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("banana", "grape", "apple")) // ["banana", "apple"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    for (element in list1) {
        if (element in list2) {
            commonElements.add(element)
        }
    }

    return commonElements
}