/**
 * Given two lists, find the common elements between them using identity comparison.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Examples:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(2, 3, 5)) // [2, 3]
 * findCommonElements(listOf("a", "b", "c"), listOf("b", "c", "d")) // ["b", "c"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Iterate over each element in list1
    for (element in list1) {
        // Check if the element appears in list2 using identity comparison
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two lists, find the common elements between them using identity comparison.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Examples:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(2, 3, 5)) // [2, 3]
 * findCommonElements(listOf("a", "b", "c"), listOf("b", "c", "d")) // ["b", "c"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the common elements between them using identity comparison.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Examples:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(2, 3, 5)) // [2, 3]
 * findCommonElements(listOf("a", "b", "c"), listOf("b", "c", "d")) // ["b", "c"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()

    // Iterate over each element in list1
    for (element in list1) {
        // Check if the element appears in list2 using identity comparison
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }

    return commonElements
}