Skip to main content
Back to problems
Leetcode
Medium
Arrays
Strings
Hash Maps
Patients With a Condition

Find patients whose medical records contain the condition substring DIAB1 in any position.

Acceptance 0%
Problem Statement

Patients With a Condition

You are given a table of patient records. Each record contains a patient id, the patient's name, and a list of diagnoses stored as a space-separated string.

Return the patient_id and patient_name for every patient whose diagnosis string contains the substring DIAB1 anywhere in the text.

Notes

  • A match can appear at the beginning, middle, or end of the string.
  • The condition may be part of a longer token, but the required substring must appear exactly as DIAB1.
  • Return the qualifying patients in any order unless the source system specifies otherwise.

Input Format

A table Patients with columns:

  • patient_id — integer
  • patient_name — string
  • conditions — string containing one or more space-separated diagnosis codes

Output Format

Return a table with:

  • patient_id
  • patient_name

Include only rows where conditions contains DIAB1.

Constraints

  • conditions is a non-null string.
  • The substring match is case-sensitive.
  • No duplicate patient ids are expected.
  • Use exact substring matching for DIAB1.
Examples
Sample cases returned by the problem API.

Example 1

Input

Patients table:

| patient_id | patient_name | conditions          |
|------------|--------------|---------------------|
| 1          | Daniel       | FEVER DIAB1         |
| 2          | Alice        | ASTHMA              |
| 3          | Bob          | DIAB100 COLD        |
| 4          | Carol        | COLD DIAB1 DIAB2    |

Output

| patient_id | patient_name |
|------------|--------------|
| 1          | Daniel       |
| 3          | Bob          |
| 4          | Carol        |

Explanation

Rows 1, 3, and 4 contain the substring DIAB1 in the conditions column.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.