Count Fit Records Across Pages
Updated
Problem statement
Count medical records whose diastolic blood-pressure reading is inside an inclusive range.
For this exercise, assume pages contains the complete set of response pages. Each row represents one fetched page, and each integer is the vitals.bloodPressureDiastole value from one record. The source API's other fields are left out.
Return the number of supplied records whose reading is at least lowerlimit and at most upperlimit. Equal readings in different records all count. Visit every page, including pages after an empty one.
The page list and individual pages may be empty. All inputs are well formed. The page matrix is an extra argument for this practice exercise; no HTTP request or JSON parsing is required.
Function
healthCheckup(pages: int[][], lowerlimit: int, upperlimit: int) → intExamples
Example 1
pages = [[80,90,110],[95],[]]lowerlimit = 90upperlimit = 100return = 2The first page contributes the reading 90, the second contributes 95, and the empty page contributes none. Both endpoints are included, so the count is 2.
Example 2
pages = [[],[70,70,80],[],[70]]lowerlimit = 70upperlimit = 70return = 3All three records with reading 70 count, even though two have the same value on one page and another comes after an empty page. The reading 80 is outside the range.
Example 3
pages = []lowerlimit = 0upperlimit = 300return = 0There are no supplied pages, so there are no records to count.
Constraints
0 <= pages.length <= 50.0 <= pages[i].length <= 1000.0 <= pages[i][j] <= 300, with integer readings.0 <= lowerlimit <= upperlimit <= 300.
More Palantir Online Assessment questions
- Basic Item DiscountsOA · Seen Nov 2026
- Optimize Discount Selection Under a Point BudgetOA · Seen Nov 2026
- Stacked Item and Category DiscountsOA · Seen Nov 2026
- Minimize Path ValueOA · Seen Sep 2024
- No Pairs AllowedOA · Seen Sep 2024
- REST API: Country CodesOA · Seen Feb 2024
- Swap ParityOA · Seen Feb 2024
- Freelance Candidate ReviewOA · Seen Nov 2023
- Benchmarking Tool ReportOA · Seen Sep 2023
- Network FormationOA · Seen Sep 2023
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Two SumAmazon · OA · PHONE SCREEN
- Count Strictly Increasing Contiguous WindowsIBM · OAIBM interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Server InvestmentRippling · OARippling interview questions
- Book Reading EveningsGoogle · OAGoogle interview questions
- Minimum Index Distance Between Person and CakeSnowflake · OA · PHONE SCREENSnowflake interview questions
- Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions