/**
 * Given a nurse's name and a list of patients, returns a new list containing the patients that the
 * nurse needs to attend, in alphabetical order.
 *
 * @param nurse The name of the nurse.
 * @param patients A nested list containing the patient names associated with the nurse.
 * @return A new list containing the names of the patients that the nurse needs to attend, sorted in alphabetical order.
 */
fun findPatients(nurse: String, patients: List<List<String>>): List<String> {

    val attendedPatients = mutableListOf<String>()

    for (patientGroup in patients) {
        if (nurse in patientGroup) {
            attendedPatients.addAll(patientGroup.subList(1, patientGroup.size))
        } else {
            attendedPatients.add(patientGroup[0])
        }
    }

    return attendedPatients.toSet().sorted()
}
/**
 * Given a nurse's name and a list of patients, returns a new list containing the patients that the
 * nurse needs to attend, in alphabetical order.
 *
 * @param nurse The name of the nurse.
 * @param patients A nested list containing the patient names associated with the nurse.
 * @return A new list containing the names of the patients that the nurse needs to attend, sorted in alphabetical order.
 */
fun findPatients(nurse: String, patients: List<List<String>>): List<String> {
/**
 * Given a nurse's name and a list of patients, returns a new list containing the patients that the
 * nurse needs to attend, in alphabetical order.
 *
 * @param nurse The name of the nurse.
 * @param patients A nested list containing the patient names associated with the nurse.
 * @return A new list containing the names of the patients that the nurse needs to attend, sorted in alphabetical order.
 */
fun findPatients(nurse: String, patients: List<List<String>>): List<String> {

    val attendedPatients = mutableListOf<String>()

    for (patientGroup in patients) {
        if (nurse in patientGroup) {
            attendedPatients.addAll(patientGroup.subList(1, patientGroup.size))
        } else {
            attendedPatients.add(patientGroup[0])
        }
    }

    return attendedPatients.toSet().sorted()
}