← 返回 oracle 的题目列表Medical Records By Age
类型:online_judge
Medical Records By Age
A paginated REST API provides patient medical records through HTTP GET. The base URL is supplied by the code stub. Request a page by appending a page parameter:
<base_url>?page=1
Every response is a JSON object of the following form:
{
"page": 1,
"per_page": 10,
"total": 99,
"total_pages": 10,
"data": [ ... ]
}
Each item in data contains an id, a UTC millisecond timestamp, userDob in DD-MM-YYYY format, and a vitals object containing bloodPressureDiastole and bloodPressureSystole.
Implement getRecordsByAgeGroup(ageStart, ageEnd, bpDiff):
Fetch records from all pages of the API.
For every record, compute the patient's completed age on the record's UTC date, using userDob and the record timestamp.
Keep a record when:
ageStart <= age <= ageEnd; and
bloodPressureDiastole - bloodPressureSystole > bpDiff.
Return matching record IDs in ascending numeric order.
Return [-1] when no records match.
Parameters
ageStart: inclusive minimum age.
ageEnd: inclusive maximum age.
bpDiff: threshold for the diastolic-minus-systolic pressure difference.
Constraints
0 <= ageStart, ageEnd, bpDiff <= 10^2
Custom Input
ageStart
ageEnd
bpDiff
Example
Input:
28
30
63
Output:
31
The original wording conflicts on whether the blood-pressure comparison is > or <. This version follows the explicit filter expression: bloodPressureDiastole - bloodPressureSystole > bpDiff.
Example
Input
28
30
63
Output
31