/**
 * This exercise aims to find the common elements between two lists using nested loops.
 *
 * @param list1 The first list containing elements.
 * @param list2 The second list containing 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]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    for (element1 in list1) {
        for (element2 in list2) {
            if (element1 == element2) {
                commonElements.add(element1)
                break
            }
        }
    }

    return commonElements
}
/**
 * This exercise aims to find the common elements between two lists using nested loops.
 *
 * @param list1 The first list containing elements.
 * @param list2 The second list containing 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]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This exercise aims to find the common elements between two lists using nested loops.
 *
 * @param list1 The first list containing elements.
 * @param list2 The second list containing 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]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    for (element1 in list1) {
        for (element2 in list2) {
            if (element1 == element2) {
                commonElements.add(element1)
                break
            }
        }
    }

    return commonElements
}