Hospital Triage Priority Scheduling : Asked in Goldman Sach

Posted
19 Feb 2026
388 reads

Summary

This post details a specific coding interview question encountered during an interview experience at Goldman Sachs, focusing on a hospital triage priority scheduling problem with basic and extended versions.

How it went

Hospital Triage Priority Scheduling:

In a hospital emergency room, patients are treated based on the severity of their condition.

You are given:

An integer array severities[], where severities[i] represents the severity level of the patient who arrived at time i.

An integer k, representing the index of a specific patient.

Additionally, in the extended version of the problem, you are also given:

A character array gender[], where gender[i] is either 'M' (Male) or 'F' (Female).

Basic Version (Without Gender)

A patient with higher severity is treated first.

If two patients have the same severity, the patient who arrived earlier (smaller index) is treated first.

Treatment order starts from 1 (1-based indexing).

Extended Version (With Gender Priority)

Higher severity first.

If severity is the same:

Female patients ('F') are treated before Male patients ('M').

If both severity and gender are the same:

Earlier arrival (smaller index) is treated first.

Treatment order is 1-based.

Task

Return the treatment order of the patient at index k.

Example 1 (Basic Version) Input: severities = [3, 1, 4, 4, 2] k = 2

Explanation:

Treatment order:

Index 2 (severity 4)

Index 3 (severity 4)

Index 0 (severity 3)

Index 4 (severity 2)

Index 1 (severity 1)

Patient at index 2 is treated first.

Output: 1

Example 2 (Extended Version) Input: severities = [3, 1, 4, 4, 2] gender = ['M', 'F', 'M', 'F', 'M'] k = 2

Explanation:

Highest severity = 4 Patients at index 2 (M) and 3 (F).

Since severity is equal and Female has priority:

Index 3 (severity 4, Female)

Index 2 (severity 4, Male)

Index 0

Index 4

Index 1

Patient at index 2 is treated second.

Output: 2

Constraints

1 ≤ severities.length ≤ 10^5

1 ≤ severities[i] ≤ 10^9

0 ≤ k < severities.length

For extended version:

gender.length == severities.length

gender[i] ∈ {'M', 'F'}

Questions asked (1)

  1. 01

    Hospital Triage Priority Scheduling

    Data Structures & Algorithms · Medium

    In a hospital emergency room, patients are treated based on the severity of their condition.

    You are given:

    An integer array severities[], where severities[i] represents the severity level of the patient who arrived at time i.

    An integer k, representing the index of a specific patient.

    Additionally, in the extended version of the problem, you are also given:

    A character array gender[], where gender[i] is either 'M' (Male) or 'F' (Female).

    Basic Version (Without Gender)

    A patient with higher severity is treated first.

    If two patients have the same severity, the patient who arrived earlier (smaller index) is treated first.

    Treatment order starts from 1 (1-based indexing).

    Extended Version (With Gender Priority)

    Higher severity first.

    If severity is the same:

    Female patients ('F') are treated before Male patients ('M').

    If both severity and gender are the same:

    Earlier arrival (smaller index) is treated first.

    Treatment order is 1-based.

    Task

    Return the treatment order of the patient at index k.

    Example 1 (Basic Version) Input: severities = [3, 1, 4, 4, 2] k = 2

    Explanation:

    Treatment order:

    Index 2 (severity 4)

    Index 3 (severity 4)

    Index 0 (severity 3)

    Index 4 (severity 2)

    Index 1 (severity 1)

    Patient at index 2 is treated first.

    Output: 1

    Example 2 (Extended Version) Input: severities = [3, 1, 4, 4, 2] gender = ['M', 'F', 'M', 'F', 'M'] k = 2

    Explanation:

    Highest severity = 4 Patients at index 2 (M) and 3 (F).

    Since severity is equal and Female has priority:

    Index 3 (severity 4, Female)

    Index 2 (severity 4, Male)

    Index 0

    Index 4

    Index 1

    Patient at index 2 is treated second.

    Output: 2

    Constraints

    1 ≤ severities.length ≤ 10^5

    1 ≤ severities[i] ≤ 10^9

    0 ≤ k < severities.length

    For extended version:

    gender.length == severities.length

    gender[i] ∈ {'M', 'F'}

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Goldman Sachs recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!