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

    return list1.toSet().filter { it in list2 }
}

val listA = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val listB = listOf(5, 10, 15, 20, 25, 30, 35, 40, 45, 50)
val listC = listOf(3, 6, 9, 12, 15, 18, 21)
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first input list.
 * @param list2 The second input list.
 * @return A list of common elements found in both input lists.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("orange", "kiwi", "pineapple")) // ["orange"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, find the common elements between them.
 *
 * @param list1 The first input list.
 * @param list2 The second input list.
 * @return A list of common elements found in both input lists.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf("apple", "banana", "orange"), listOf("orange", "kiwi", "pineapple")) // ["orange"]
 */
fun findCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    return list1.toSet().filter { it in list2 }
}

val listA = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
val listB = listOf(5, 10, 15, 20, 25, 30, 35, 40, 45, 50)
val listC = listOf(3, 6, 9, 12, 15, 18, 21)