/**
 * Given two arrays, find the intersection (common elements) between them.
 *
 * @param array1 First array
 * @param array2 Second array
 * @return An array containing the common elements between the input arrays
 *
 * Example:
 * findIntersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findIntersection(array1: List<Int>, array2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (element in array1) {
        if (element in array2 && element !in commonElements) {
            commonElements.add(element)
        }
    }
    return commonElements
}
/**
 * Given two arrays, find the intersection (common elements) between them.
 *
 * @param array1 First array
 * @param array2 Second array
 * @return An array containing the common elements between the input arrays
 *
 * Example:
 * findIntersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findIntersection(array1: List<Int>, array2: List<Int>): List<Int> {
/**
 * Given two arrays, find the intersection (common elements) between them.
 *
 * @param array1 First array
 * @param array2 Second array
 * @return An array containing the common elements between the input arrays
 *
 * Example:
 * findIntersection(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 */
fun findIntersection(array1: List<Int>, array2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()
    for (element in array1) {
        if (element in array2 && element !in commonElements) {
            commonElements.add(element)
        }
    }
    return commonElements
}