/**
 * This function finds the common elements between two given lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 20, 30, 40, 50), listOf(15, 25, 25, 35, 45, 55)) // []
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    // Iterate over each element in list1
    for (element in list1) {
        // Check if the element is present in list2
        if (element in list2) {
            // Append the element to the intersection list
            intersection.add(element)
        }
    }
    return intersection
}
/**
 * This function finds the common elements between two given lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 20, 30, 40, 50), listOf(15, 25, 25, 35, 45, 55)) // []
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This function finds the common elements between two given lists.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A list containing the common elements.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 20, 30, 40, 50), listOf(15, 25, 25, 35, 45, 55)) // []
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()
    // Iterate over each element in list1
    for (element in list1) {
        // Check if the element is present in list2
        if (element in list2) {
            // Append the element to the intersection list
            intersection.add(element)
        }
    }
    return intersection
}