/**
 * Given two ranges, find the intersection of the two ranges.
 *
 * @param range1 A Pair representing the first range with negative values
 * @param range2 A Pair representing the second range
 * @return A Pair representing the intersection of the two ranges, or an empty Pair if there is no intersection
 *
 * Example:
 * findIntersection(Pair(-5, 5), Pair(-2, 8)) returns Pair(-2, 5)
 * findIntersection(Pair(-10, 0), Pair(-5, 5)) returns Pair(-5, 0)
 * findIntersection(Pair(1, 10), Pair(11, 20)) returns Pair(0, 0)
 */
fun findIntersection(range1: Pair<Int, Int>, range2: Pair<Int, Int>): Pair<Int, Int> {

    val (start1, end1) = range1
    val (start2, end2) = range2

    val start = if (start1 < start2) start2 else start1
    val end = if (end1 < end2) end1 else end2

    return if (start <= end) Pair(start, end) else Pair(0, 0)
}
/**
 * Given two ranges, find the intersection of the two ranges.
 *
 * @param range1 A Pair representing the first range with negative values
 * @param range2 A Pair representing the second range
 * @return A Pair representing the intersection of the two ranges, or an empty Pair if there is no intersection
 *
 * Example:
 * findIntersection(Pair(-5, 5), Pair(-2, 8)) returns Pair(-2, 5)
 * findIntersection(Pair(-10, 0), Pair(-5, 5)) returns Pair(-5, 0)
 * findIntersection(Pair(1, 10), Pair(11, 20)) returns Pair(0, 0)
 */
fun findIntersection(range1: Pair<Int, Int>, range2: Pair<Int, Int>): Pair<Int, Int> {
/**
 * Given two ranges, find the intersection of the two ranges.
 *
 * @param range1 A Pair representing the first range with negative values
 * @param range2 A Pair representing the second range
 * @return A Pair representing the intersection of the two ranges, or an empty Pair if there is no intersection
 *
 * Example:
 * findIntersection(Pair(-5, 5), Pair(-2, 8)) returns Pair(-2, 5)
 * findIntersection(Pair(-10, 0), Pair(-5, 5)) returns Pair(-5, 0)
 * findIntersection(Pair(1, 10), Pair(11, 20)) returns Pair(0, 0)
 */
fun findIntersection(range1: Pair<Int, Int>, range2: Pair<Int, Int>): Pair<Int, Int> {

    val (start1, end1) = range1
    val (start2, end2) = range2

    val start = if (start1 < start2) start2 else start1
    val end = if (end1 < end2) end1 else end2

    return if (start <= end) Pair(start, end) else Pair(0, 0)
}