Problem · Array
Count Paginated Medical Records in a Range
Learn this problemProblem statement
A medical-records API returns a paginated response. For this network-free practice version, pages[i] contains the integer values of the requested record field returned on API page i + 1.
A record qualifies when its field value lies in the inclusive interval from lowerBound through upperBound.
Return the total number of qualifying records across every page.
Function
countMedicalRecordsInRange(pages: int[][], lowerBound: int, upperBound: int) → intExamples
Example 1
pages = [[110,125,120],[100,115],[]]lowerBound = 110upperBound = 120return = 3The qualifying values are 110, 120, and 115. Values 125 and 100 fall outside the inclusive interval, and the empty page contributes no records.
Constraints
pagesand any of its rows may be empty.- Every field value,
lowerBound, andupperBoundfits in a signed 32-bit integer. lowerBound ≤ upperBound.