/**
 * Given two lists, find the common elements present in both lists.
 *
 * @param list1 A list of numbers
 * @param list2 A list of numbers
 * @return A list of common elements present in both input lists
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) => [4, 5]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Loop through each element in list1
    for (ele1 in list1) {
        // Loop through each element in list2
        for (ele2 in list2) {
            // Check if the element in list1 is equal to the element in list2
            if (ele1 == ele2) {
                // Append the common element to the commonElements list
                commonElements.add(ele1)
                break
            }
        }
    }

    return commonElements
}
/**
 * Given two lists, find the common elements present in both lists.
 *
 * @param list1 A list of numbers
 * @param list2 A list of numbers
 * @return A list of common elements present in both input lists
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) => [4, 5]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, find the common elements present in both lists.
 *
 * @param list1 A list of numbers
 * @param list2 A list of numbers
 * @return A list of common elements present in both input lists
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7)) => [4, 5]
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Loop through each element in list1
    for (ele1 in list1) {
        // Loop through each element in list2
        for (ele2 in list2) {
            // Check if the element in list1 is equal to the element in list2
            if (ele1 == ele2) {
                // Append the common element to the commonElements list
                commonElements.add(ele1)
                break
            }
        }
    }

    return commonElements
}