/**
 * The nurse station has a number line representing the range of rooms that need to be visited.
 * In order to optimize the route, the nurse wants to iterate over a specific range of rooms.
 * Complete the function below to return the rooms that need to be visited based on the given range.
 *
 * @param nurseStation A list of integers representing the rooms in the nurse station.
 * @param start The starting room number.
 * @param end The ending room number.
 * @return A list of rooms that need to be visited based on the given range.
 */
fun intersectRangeNumberLine(nurseStation: List<Int>, start: Int, end: Int): List<Int> {

    // Check if start and end are valid room numbers
    if (start !in nurseStation || end !in nurseStation) {
        return listOf(-1) // Return an error code for invalid range
    }

    // Get the index of start and end room in the nurse station list
    val startIndex = nurseStation.indexOf(start)
    val endIndex = nurseStation.indexOf(end)

    // Iterate over the range of rooms from start index to end index
    val roomsToVisit = mutableListOf<Int>()
    for (i in startIndex..endIndex) {
        roomsToVisit.add(nurseStation[i])
    }

    return roomsToVisit
}
/**
 * The nurse station has a number line representing the range of rooms that need to be visited.
 * In order to optimize the route, the nurse wants to iterate over a specific range of rooms.
 * Complete the function below to return the rooms that need to be visited based on the given range.
 *
 * @param nurseStation A list of integers representing the rooms in the nurse station.
 * @param start The starting room number.
 * @param end The ending room number.
 * @return A list of rooms that need to be visited based on the given range.
 */
fun intersectRangeNumberLine(nurseStation: List<Int>, start: Int, end: Int): List<Int> {
/**
 * The nurse station has a number line representing the range of rooms that need to be visited.
 * In order to optimize the route, the nurse wants to iterate over a specific range of rooms.
 * Complete the function below to return the rooms that need to be visited based on the given range.
 *
 * @param nurseStation A list of integers representing the rooms in the nurse station.
 * @param start The starting room number.
 * @param end The ending room number.
 * @return A list of rooms that need to be visited based on the given range.
 */
fun intersectRangeNumberLine(nurseStation: List<Int>, start: Int, end: Int): List<Int> {

    // Check if start and end are valid room numbers
    if (start !in nurseStation || end !in nurseStation) {
        return listOf(-1) // Return an error code for invalid range
    }

    // Get the index of start and end room in the nurse station list
    val startIndex = nurseStation.indexOf(start)
    val endIndex = nurseStation.indexOf(end)

    // Iterate over the range of rooms from start index to end index
    val roomsToVisit = mutableListOf<Int>()
    for (i in startIndex..endIndex) {
        roomsToVisit.add(nurseStation[i])
    }

    return roomsToVisit
}