/**
 * Find the intersection of two sequences using slicing
 */
fun intersectSlicing(seq1: List<Int>, seq2: List<Int>): List<Int> {

    // Remove duplicates and sort the sequences
    val sortedSeq1 = seq1.toSet().sorted()
    val sortedSeq2 = seq2.toSet().sorted()

    // Initialize empty list for common elements
    val intersection = mutableListOf<Int>()

    // Initialize variables to keep track of the current indices in seq1 and seq2
    var i = 0
    var j = 0

    // Iterate until one of the sequences is fully traversed
    while (i < sortedSeq1.size && j < sortedSeq2.size) {
        // Compare the current elements of both sequences
        when {
            sortedSeq1[i] < sortedSeq2[j] -> i++
            sortedSeq1[i] > sortedSeq2[j] -> j++
            else -> {
                // Add common element to the intersection list and move to the next elements in both sequences
                intersection.add(sortedSeq1[i])
                i++
                j++
            }
        }
    }

    return intersection
}
/**
 * Find the intersection of two sequences using slicing
 */
fun intersectSlicing(seq1: List<Int>, seq2: List<Int>): List<Int> {
/**
 * Find the intersection of two sequences using slicing
 */
fun intersectSlicing(seq1: List<Int>, seq2: List<Int>): List<Int> {

    // Remove duplicates and sort the sequences
    val sortedSeq1 = seq1.toSet().sorted()
    val sortedSeq2 = seq2.toSet().sorted()

    // Initialize empty list for common elements
    val intersection = mutableListOf<Int>()

    // Initialize variables to keep track of the current indices in seq1 and seq2
    var i = 0
    var j = 0

    // Iterate until one of the sequences is fully traversed
    while (i < sortedSeq1.size && j < sortedSeq2.size) {
        // Compare the current elements of both sequences
        when {
            sortedSeq1[i] < sortedSeq2[j] -> i++
            sortedSeq1[i] > sortedSeq2[j] -> j++
            else -> {
                // Add common element to the intersection list and move to the next elements in both sequences
                intersection.add(sortedSeq1[i])
                i++
                j++
            }
        }
    }

    return intersection
}