/**
 * Given two lists, lst1 and lst2, find the intersection of the two lists using short-circuiting
 * and list slicing. Return the intersection in a new list.
 *
 * Short-circuiting allows us to stop iterating through a list as soon as the desired condition is met.
 *
 * For example, if lst1 = [1, 2, 3, 4, 5] and lst2 = [4, 5, 6, 7, 8], the intersection would be [4, 5].
 *
 * Complete the code to find the intersection of lst1 and lst2 using short-circuiting and list slicing.
 *
 * @param lst1 The first list.
 * @param lst2 The second list.
 * @return The intersection of lst1 and lst2.
 */
fun intersectionShortCircuitingListSlicing(lst1: List<Int>, lst2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    for (i in lst1.indices) {
        if (lst1[i] in lst2.subList(0, i)) {
            intersection.add(lst1[i])
        } else if (lst1[i] in lst2.subList(i, lst2.size)) {
            intersection.add(lst1[i])
        }
    }

    return intersection
}
/**
 * Given two lists, lst1 and lst2, find the intersection of the two lists using short-circuiting
 * and list slicing. Return the intersection in a new list.
 *
 * Short-circuiting allows us to stop iterating through a list as soon as the desired condition is met.
 *
 * For example, if lst1 = [1, 2, 3, 4, 5] and lst2 = [4, 5, 6, 7, 8], the intersection would be [4, 5].
 *
 * Complete the code to find the intersection of lst1 and lst2 using short-circuiting and list slicing.
 *
 * @param lst1 The first list.
 * @param lst2 The second list.
 * @return The intersection of lst1 and lst2.
 */
fun intersectionShortCircuitingListSlicing(lst1: List<Int>, lst2: List<Int>): List<Int> {
/**
 * Given two lists, lst1 and lst2, find the intersection of the two lists using short-circuiting
 * and list slicing. Return the intersection in a new list.
 *
 * Short-circuiting allows us to stop iterating through a list as soon as the desired condition is met.
 *
 * For example, if lst1 = [1, 2, 3, 4, 5] and lst2 = [4, 5, 6, 7, 8], the intersection would be [4, 5].
 *
 * Complete the code to find the intersection of lst1 and lst2 using short-circuiting and list slicing.
 *
 * @param lst1 The first list.
 * @param lst2 The second list.
 * @return The intersection of lst1 and lst2.
 */
fun intersectionShortCircuitingListSlicing(lst1: List<Int>, lst2: List<Int>): List<Int> {

    val intersection = mutableListOf<Int>()

    for (i in lst1.indices) {
        if (lst1[i] in lst2.subList(0, i)) {
            intersection.add(lst1[i])
        } else if (lst1[i] in lst2.subList(i, lst2.size)) {
            intersection.add(lst1[i])
        }
    }

    return intersection
}