/**
 * This function takes in two ranges and returns their intersection as a list.
 *
 * @param range1 A list representing the first range. The first element of the list is the start
 * of the range (inclusive), and the second element is the end of the range (exclusive).
 * @param range2 A list representing the second range, in the same format as range1.
 * @return A list representing the intersection of range1 and range2.
 *
 * Example:
 * findIntersection(listOf(1, 10), listOf(5, 15)) // [5, 9]
 */
fun findIntersection(range1: List<Int>, range2: List<Int>): List<Int> {

    val intersectionStart = maxOf(range1[0], range2[0])
    val intersectionEnd = minOf(range1[1], range2[1])
    return if (intersectionStart < intersectionEnd) {
        listOf(intersectionStart, intersectionEnd - 1)
    } else {
        emptyList()
    }
}
/**
 * This function takes in two ranges and returns their intersection as a list.
 *
 * @param range1 A list representing the first range. The first element of the list is the start
 * of the range (inclusive), and the second element is the end of the range (exclusive).
 * @param range2 A list representing the second range, in the same format as range1.
 * @return A list representing the intersection of range1 and range2.
 *
 * Example:
 * findIntersection(listOf(1, 10), listOf(5, 15)) // [5, 9]
 */
fun findIntersection(range1: List<Int>, range2: List<Int>): List<Int> {
/**
 * This function takes in two ranges and returns their intersection as a list.
 *
 * @param range1 A list representing the first range. The first element of the list is the start
 * of the range (inclusive), and the second element is the end of the range (exclusive).
 * @param range2 A list representing the second range, in the same format as range1.
 * @return A list representing the intersection of range1 and range2.
 *
 * Example:
 * findIntersection(listOf(1, 10), listOf(5, 15)) // [5, 9]
 */
fun findIntersection(range1: List<Int>, range2: List<Int>): List<Int> {

    val intersectionStart = maxOf(range1[0], range2[0])
    val intersectionEnd = minOf(range1[1], range2[1])
    return if (intersectionStart < intersectionEnd) {
        listOf(intersectionStart, intersectionEnd - 1)
    } else {
        emptyList()
    }
}