/**
 * Given two lists of integers, return a list of common elements found in both lists.
 *
 * @param list1 The first list of integers.
 * @param list2 The second list of integers.
 * @return The list of common elements found in both lists.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>() // Initialize an empty list to store common elements

    for (num1 in list1) { // Iterate through each element of list1
        for (num2 in list2) { // Iterate through each element of list2
            if (num1 == num2) { // Check if the elements are equal
                commonElements.add(num1) // Add the common element to the commonElements list
                break // Exit the inner loop as we have found a match
            }
        }
    }

    return commonElements // Return the list of common elements
}
/**
 * Given two lists of integers, return a list of common elements found in both lists.
 *
 * @param list1 The first list of integers.
 * @param list2 The second list of integers.
 * @return The list of common elements found in both lists.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists of integers, return a list of common elements found in both lists.
 *
 * @param list1 The first list of integers.
 * @param list2 The second list of integers.
 * @return The list of common elements found in both lists.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>() // Initialize an empty list to store common elements

    for (num1 in list1) { // Iterate through each element of list1
        for (num2 in list2) { // Iterate through each element of list2
            if (num1 == num2) { // Check if the elements are equal
                commonElements.add(num1) // Add the common element to the commonElements list
                break // Exit the inner loop as we have found a match
            }
        }
    }

    return commonElements // Return the list of common elements
}