Problem · Array
Hospital Triage Priority
Learn this problemProblem statement
Patient i arrives at index i with severity severities[i]. Return the 1-based treatment position of patient k.
- Greater severity is treated first.
- If
gendersis empty, equal-severity patients are ordered by earlier arrival. - Otherwise
genders.length == severities.length; at equal severity,Fis treated beforeM, then earlier arrival breaks the remaining tie.
Function
treatmentOrder(severities: int[], genders: String, k: int) → intExamples
Example 1
severities = [3,1,4,4,2]genders = ""k = 2return = 1Patient 2 is the earlier of the two severity-4 patients.
Example 2
severities = [3,1,4,4,2]genders = "MFMFM"k = 2return = 2Patient 3 is female and therefore precedes patient 2 at equal severity.
Constraints
1 <= severities.length <= 1000001 <= severities[i] <= 10^90 <= k < severities.lengthgendersis empty or has the same length asseveritiesand contains onlyMandF.