/**
 * Given two sequences, find the common elements between them.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return A list containing the common elements between sequence1 and sequence2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun findCommonElements(sequence1: List<Int>, sequence2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate over the first sequence
    for (element in sequence1) {
        // Check if the element is also present in the second sequence
        if (element in sequence2) {
            // Append the common element to the result list
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two sequences, find the common elements between them.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return A list containing the common elements between sequence1 and sequence2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun findCommonElements(sequence1: List<Int>, sequence2: List<Int>): List<Int> {
/**
 * Given two sequences, find the common elements between them.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return A list containing the common elements between sequence1 and sequence2.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun findCommonElements(sequence1: List<Int>, sequence2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Iterate over the first sequence
    for (element in sequence1) {
        // Check if the element is also present in the second sequence
        if (element in sequence2) {
            // Append the common element to the result list
            commonElements.add(element)
        }
    }

    return commonElements
}