Fetch and aggregate paginated team data via API
ReevoSoftware Engineer · Online AssessmentLast updated
This question evaluates API integration, pagination handling, robust error handling (retries/backoff and rate-limit awareness), data aggregation, sorting and top‑N selection skills within the Data Manipulation (SQL/Python) domain.
Implement a function getTopTeams(baseUrl, n) that calls a paginated HTTP API returning a JSON array of team objects on each page: [{"name": string, "wins": integer}]. Pagination is controlled by appending &page=<number> to baseUrl (pages start at 1 and continue until an empty or missing page is encountered). Retrieve and merge all pages, sort teams by wins descending then name ascending, and return the top n team names. Handle pagination, transient network errors (with retries/backoff), rate limits, and malformed records.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.