/**
 * Given two arrays, find the common elements between them and return a new array containing those elements.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A new array containing the common elements between array1 and array2.
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {

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

    // Iterate through each element in array1
    for (element1 in array1) {
        // Check if the element is also present in array2
        if (element1 in array2) {
            // Append the element to the commonElements list
            commonElements.add(element1)
        }
    }

    return commonElements
}
/**
 * Given two arrays, find the common elements between them and return a new array containing those elements.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A new array containing the common elements between array1 and array2.
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {
/**
 * Given two arrays, find the common elements between them and return a new array containing those elements.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A new array containing the common elements between array1 and array2.
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {

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

    // Iterate through each element in array1
    for (element1 in array1) {
        // Check if the element is also present in array2
        if (element1 in array2) {
            // Append the element to the commonElements list
            commonElements.add(element1)
        }
    }

    return commonElements
}