/**
 * This exercise requires you to find the intersection of two number line representations. You will be given the nurse's phone number in the form of a list and the patient's phone number in the form of another list. Your task is to find the common numbers in both lists and return them as a new list, sorted in ascending order. The nurse's phone number and the patient's phone number will contain only unique, positive integer values.
 *
 * For example, if the nurse's phone number is [1, 3, 4, 7, 9] and the patient's phone number is [2, 4, 6, 7, 8], the common numbers between them are 4 and 7. So the output should be [4, 7].
 *
 * Your code should be able to handle larger lists efficiently.
 */
fun nursePatientIntersection(nursePhone: List<Int>, patientPhone: List<Int>): List<Int> {

    // Find the intersection by converting the nurse and patient phone numbers into sets,
    // and perform set intersection operation to get the common numbers.
    val intersection = nursePhone.toSet().intersect(patientPhone.toSet())

    // Sort the numbers in the intersection set and return as a list
    return intersection.sorted()
}
/**
 * This exercise requires you to find the intersection of two number line representations. You will be given the nurse's phone number in the form of a list and the patient's phone number in the form of another list. Your task is to find the common numbers in both lists and return them as a new list, sorted in ascending order. The nurse's phone number and the patient's phone number will contain only unique, positive integer values.
 *
 * For example, if the nurse's phone number is [1, 3, 4, 7, 9] and the patient's phone number is [2, 4, 6, 7, 8], the common numbers between them are 4 and 7. So the output should be [4, 7].
 *
 * Your code should be able to handle larger lists efficiently.
 */
fun nursePatientIntersection(nursePhone: List<Int>, patientPhone: List<Int>): List<Int> {
/**
 * This exercise requires you to find the intersection of two number line representations. You will be given the nurse's phone number in the form of a list and the patient's phone number in the form of another list. Your task is to find the common numbers in both lists and return them as a new list, sorted in ascending order. The nurse's phone number and the patient's phone number will contain only unique, positive integer values.
 *
 * For example, if the nurse's phone number is [1, 3, 4, 7, 9] and the patient's phone number is [2, 4, 6, 7, 8], the common numbers between them are 4 and 7. So the output should be [4, 7].
 *
 * Your code should be able to handle larger lists efficiently.
 */
fun nursePatientIntersection(nursePhone: List<Int>, patientPhone: List<Int>): List<Int> {

    // Find the intersection by converting the nurse and patient phone numbers into sets,
    // and perform set intersection operation to get the common numbers.
    val intersection = nursePhone.toSet().intersect(patientPhone.toSet())

    // Sort the numbers in the intersection set and return as a list
    return intersection.sorted()
}