/**
 * Given two arrays of integers, find and return a list containing the common elements between them.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A list of common elements between the two arrays.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 20, 30), listOf(5, 10, 15, 20, 25, 30)) // [10, 20, 30]
 * findCommonElements(listOf(1, 2, 3), listOf(4, 5, 6)) // []
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate through each number in the first array
    for (num in array1) {
        // Check if the number is present in the second array
        if (num in array2) {
            commonElements.add(num)
        }
    }

    return commonElements
}
/**
 * Given two arrays of integers, find and return a list containing the common elements between them.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A list of common elements between the two arrays.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 20, 30), listOf(5, 10, 15, 20, 25, 30)) // [10, 20, 30]
 * findCommonElements(listOf(1, 2, 3), listOf(4, 5, 6)) // []
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {
/**
 * Given two arrays of integers, find and return a list containing the common elements between them.
 *
 * @param array1 The first array.
 * @param array2 The second array.
 * @return A list of common elements between the two arrays.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonElements(listOf(10, 20, 30), listOf(5, 10, 15, 20, 25, 30)) // [10, 20, 30]
 * findCommonElements(listOf(1, 2, 3), listOf(4, 5, 6)) // []
 */
fun findCommonElements(array1: List<Int>, array2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate through each number in the first array
    for (num in array1) {
        // Check if the number is present in the second array
        if (num in array2) {
            commonElements.add(num)
        }
    }

    return commonElements
}