/**
 * Given two lists, find the common elements between them and return a list of these elements.
 *
 * @param list1 a list of integers
 * @param list2 a list of integers
 * @return a list of integers representing the common elements between list1 and list2
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate through the elements of list1
    for (element in list1) {
        // Check if the element is in list2
        if (list2.contains(element)) {
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two lists, find the common elements between them and return a list of these elements.
 *
 * @param list1 a list of integers
 * @param list2 a list of integers
 * @return a list of integers representing the common elements between list1 and list2
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, find the common elements between them and return a list of these elements.
 *
 * @param list1 a list of integers
 * @param list2 a list of integers
 * @return a list of integers representing the common elements between list1 and list2
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate through the elements of list1
    for (element in list1) {
        // Check if the element is in list2
        if (list2.contains(element)) {
            commonElements.add(element)
        }
    }

    return commonElements
}