/**
 * This function takes two arrays as input and returns a list of common elements between them.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A list of common elements between the two arrays.
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {

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

    // Iterate through each element in array1
    for (num1 in array1) {
        // Check if the current element is in array2 or commonElements
        if (num1 in array2 || num1 in commonElements) {
            // Add the common element to the list
            commonElements.add(num1)
        }
    }

    return commonElements
}
/**
 * This function takes two arrays as input and returns a list of common elements between them.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A list of common elements between the two arrays.
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {
/**
 * This function takes two arrays as input and returns a list of common elements between them.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A list of common elements between the two arrays.
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {

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

    // Iterate through each element in array1
    for (num1 in array1) {
        // Check if the current element is in array2 or commonElements
        if (num1 in array2 || num1 in commonElements) {
            // Add the common element to the list
            commonElements.add(num1)
        }
    }

    return commonElements
}