Problem · Array

Count Paginated Medical Records in a Range

Learn this problem
EasyIBM logoIBMINTERNOA
See IBM hiring insights

Problem 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) → int

Examples

Example 1

pages = [[110,125,120],[100,115],[]]lowerBound = 110upperBound = 120return = 3

The qualifying values are 110, 120, and 115. Values 125 and 100 fall outside the inclusive interval, and the empty page contributes no records.

Constraints

  • pages and any of its rows may be empty.
  • Every field value, lowerBound, and upperBound fits in a signed 32-bit integer.
  • lowerBound ≤ upperBound.

More IBM problems

drafts saved locally
public int countMedicalRecordsInRange(int[][] pages, int lowerBound, int upperBound) {
  // Write your code here
}
pages[[110,125,120],[100,115],[]]
lowerBound110
upperBound120
expected3
checking account