/**
 * This function checks the intersection of two given sequences and returns a list of common elements.
 *
 * @param sequence1 The first sequence to be checked
 * @param sequence2 The second sequence to be checked
 * @return A list of common elements
 *
 * Example:
 * checkIntersectionOfSequences(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun checkIntersectionOfSequences(sequence1: List<Int>, sequence2: List<Int>): List<Int> {

    val result = mutableListOf<Int>()
    for (element1 in sequence1) {
        if (element1 in sequence2) {
            result.add(element1)
        }
    }
    return result
}
/**
 * This function checks the intersection of two given sequences and returns a list of common elements.
 *
 * @param sequence1 The first sequence to be checked
 * @param sequence2 The second sequence to be checked
 * @return A list of common elements
 *
 * Example:
 * checkIntersectionOfSequences(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun checkIntersectionOfSequences(sequence1: List<Int>, sequence2: List<Int>): List<Int> {
/**
 * This function checks the intersection of two given sequences and returns a list of common elements.
 *
 * @param sequence1 The first sequence to be checked
 * @param sequence2 The second sequence to be checked
 * @return A list of common elements
 *
 * Example:
 * checkIntersectionOfSequences(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) => [4, 5]
 */
fun checkIntersectionOfSequences(sequence1: List<Int>, sequence2: List<Int>): List<Int> {

    val result = mutableListOf<Int>()
    for (element1 in sequence1) {
        if (element1 in sequence2) {
            result.add(element1)
        }
    }
    return result
}