/**
 * This function takes two lists as input and finds the common elements between them.
 * The common elements are then appended to a new list and returned.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    // Convert the input lists into sets for efficient intersection operation
    val set1 = list1.toSet()
    val set2 = list2.toSet()

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

    // Iterate over each element in set1
    for (element1 in set1) {
        // Iterate over each element in set2
        for (element2 in set2) {
            // Check if the current element in set1 is equal to the current element in set2
            if (element1 == element2) {
                // Append the common element to the commonElements list
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}
/**
 * This function takes two lists as input and finds the common elements between them.
 * The common elements are then appended to a new list and returned.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * This function takes two lists as input and finds the common elements between them.
 * The common elements are then appended to a new list and returned.
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    // Convert the input lists into sets for efficient intersection operation
    val set1 = list1.toSet()
    val set2 = list2.toSet()

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

    // Iterate over each element in set1
    for (element1 in set1) {
        // Iterate over each element in set2
        for (element2 in set2) {
            // Check if the current element in set1 is equal to the current element in set2
            if (element1 == element2) {
                // Append the common element to the commonElements list
                commonElements.add(element1)
            }
        }
    }

    return commonElements
}