/**
 * This function takes two lists of distances and checks if there is any intersection between them.
 *
 * @param distances1 The first list of distances
 * @param distances2 The second list of distances
 * @return True if there is an intersection between the two lists, False otherwise
 */
fun intersectionCheck(distances1: MutableList<Int>, distances2: MutableList<Int>): Boolean {

    // Sort the two lists of distances in ascending order
    distances1.sort()
    distances2.sort()

    // Check for intersection using while loop and complement operator
    var index1 = 0
    var index2 = 0

    while (index1 < distances1.size && index2 < distances2.size) {
        when {
            distances1[index1] == distances2[index2] -> return true
            distances1[index1] < distances2[index2] -> index1++
            else -> index2++
        }
    }

    return false
}

// Example usage
/**
 * This function takes two lists of distances and checks if there is any intersection between them.
 *
 * @param distances1 The first list of distances
 * @param distances2 The second list of distances
 * @return True if there is an intersection between the two lists, False otherwise
 */
fun intersectionCheck(distances1: MutableList<Int>, distances2: MutableList<Int>): Boolean {
/**
 * This function takes two lists of distances and checks if there is any intersection between them.
 *
 * @param distances1 The first list of distances
 * @param distances2 The second list of distances
 * @return True if there is an intersection between the two lists, False otherwise
 */
fun intersectionCheck(distances1: MutableList<Int>, distances2: MutableList<Int>): Boolean {

    // Sort the two lists of distances in ascending order
    distances1.sort()
    distances2.sort()

    // Check for intersection using while loop and complement operator
    var index1 = 0
    var index2 = 0

    while (index1 < distances1.size && index2 < distances2.size) {
        when {
            distances1[index1] == distances2[index2] -> return true
            distances1[index1] < distances2[index2] -> index1++
            else -> index2++
        }
    }

    return false
}

// Example usage