Filter Paginated Medical Records
Updated
Problem statement
Filter a paginated collection of synthetic medical records using ordinary comparisons and the average of historical weight measurements.
Pages
The array records contains all fetched pages joined together in page order. Each full page has ten records; the final page may be shorter. Rows 0..9 form the first page, rows 10..19 form the second, and so on. An empty array represents no records. All records are supplied in the input; no network request is needed.
Each row is [recordId, age]. All record IDs are unique. Each weightHistory row is [recordId, weight] and contributes one historical measurement, including repeated equal measurements. History rows may be interleaved and unordered; every referenced ID occurs in records.
A record qualifies when all of these are true:
- Its age is between
minAgeandmaxAge, inclusive. - It has at least one historical weight measurement.
- The average of all its historical weights is between
minAverageWeightandmaxAverageWeight, inclusive.
Use the exact unrounded mean. All weights and weight bounds use the same arbitrary integer unit. Return the IDs of qualifying records in their original page-and-row order. An empty result is allowed. The age fields, threshold ranges, handling of missing history and this output shape were added for this practice version. They are not from the original question.
Function
filterMedicalRecords(records: int[][], weightHistory: int[][], minAge: int, maxAge: int, minAverageWeight: int, maxAverageWeight: int) → int[]Examples
Example 1
records = [[1,25],[2,40],[3,30]]weightHistory = [[1,60],[1,80],[2,65],[3,90]]minAge = 20maxAge = 35minAverageWeight = 65maxAverageWeight = 85return = [1]Record 1 has age 25 and mean weight 70. Record 2 fails age; record 3 fails average weight.
Example 2
records = [[1,30],[2,30],[3,30],[4,30],[5,30],[6,30],[7,30],[8,30],[9,30],[10,30],[11,30]]weightHistory = [[11,75]]minAge = 20maxAge = 40minAverageWeight = 70maxAverageWeight = 80return = [11]Only record 11 has history; it is on the second page and qualifies.
Example 3
records = []weightHistory = []minAge = 0maxAge = 120minAverageWeight = 0maxAverageWeight = 10000000return = []An empty concatenation of pages has no qualifying records.
Constraints
0 <= records.length <= 256and0 <= weightHistory.length <= 512.- Every row in either matrix has exactly two integers.
- Record IDs are distinct integers from
1through10^9; every history ID belongs to one record. 0 <= age <= 120and1 <= weight <= 10^7.0 <= minAge <= maxAge <= 120.0 <= minAverageWeight <= maxAverageWeight <= 10^7.- Sums and threshold products may exceed signed
32-bit range; signed64-bit arithmetic is sufficient.
More NVIDIA Phone Screen questions
- Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
- Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
- Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
- Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
- Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
- Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
- Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
- Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
- Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
- Merge Multiple Sorted StreamsPHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- Count Product-Divisible PairsMotive · PHONE SCREENMotive interview questions
- Pair Up an Array So Every Pair Sum Divides by kAdobe · PHONE SCREENAdobe interview questions
- Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Max Points on a LineUber · PHONE SCREENUber interview questions
- Average Grades per StudentHartford Financial Services · PHONE SCREENHartford Financial Services interview questions
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
- Get Triplet CountIBM · OAIBM interview questions