/**
 * This exercise is designed to help you practice using for loops and negative indexing.
 * Your task is to write a function that takes two sequences and returns a list of their common elements, using negative indexing to access the elements from the end of the sequences.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return List of common elements between sequence1 and sequence2.
 *
 * Instructions:
 * - Use two nested for loops to iterate over each element in sequence1 and sequence2.
 * - Use negative indexing to compare the elements from the end of the sequences.
 * - If a common element is found, append it to the common_elements list.
 * - Return the common_elements list.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(6, 7, 8, 9, 10, 5, 3, 1)) // [1, 3, 5]
 */
fun findCommonElements(sequence1: List<Int>, sequence2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Write your code here

    return commonElements
}
/**
 * This exercise is designed to help you practice using for loops and negative indexing.
 * Your task is to write a function that takes two sequences and returns a list of their common elements, using negative indexing to access the elements from the end of the sequences.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return List of common elements between sequence1 and sequence2.
 *
 * Instructions:
 * - Use two nested for loops to iterate over each element in sequence1 and sequence2.
 * - Use negative indexing to compare the elements from the end of the sequences.
 * - If a common element is found, append it to the common_elements list.
 * - Return the common_elements list.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(6, 7, 8, 9, 10, 5, 3, 1)) // [1, 3, 5]
 */
fun findCommonElements(sequence1: List<Int>, sequence2: List<Int>): List<Int> {
/**
 * This exercise is designed to help you practice using for loops and negative indexing.
 * Your task is to write a function that takes two sequences and returns a list of their common elements, using negative indexing to access the elements from the end of the sequences.
 *
 * @param sequence1 The first sequence.
 * @param sequence2 The second sequence.
 * @return List of common elements between sequence1 and sequence2.
 *
 * Instructions:
 * - Use two nested for loops to iterate over each element in sequence1 and sequence2.
 * - Use negative indexing to compare the elements from the end of the sequences.
 * - If a common element is found, append it to the common_elements list.
 * - Return the common_elements list.
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4, 5), listOf(6, 7, 8, 9, 10, 5, 3, 1)) // [1, 3, 5]
 */
fun findCommonElements(sequence1: List<Int>, sequence2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Write your code here

    return commonElements
}