FastPrepCount Paginated Medical Records in a Range

Count Paginated Medical Records in a Range

IBM logoIBM● EasyINTERNNEW GRADOA
Learn

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.

Source note: These screenshots show the paginated HackerRank medical-records API schema from two independent IBM OA source sightings. Both crops omit the requested filter field and the complete callable contract.

More IBM problems

See IBM hiring insights
public int countMedicalRecordsInRange(int[][] pages, int lowerBound, int upperBound) {
  // Write your code here
}
pages[[110,125,120],[100,115],[]]
lowerBound110
upperBound120
expected3
Checking account…