Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

LeetCode Easy With API Implementation

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is LeetCode Easy With API Implementation. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Notion API list endpoints return results across multiple cursor-based response pages. Given the already fetched responses in request order, implement a helper that combines the results arrays into one list and stops when a response has no next_cursor.

Formal Specification

Implement collect_notion_results(responses). The input is a list of dictionaries matching the relevant Notion API response shape:

  • results is a list of items, which may be empty.
  • next_cursor is either a string cursor or null when there are no more pages.

Return one list containing all results from the first page through the page whose next_cursor is null. Ignore any responses after that terminal page. Preserve the original order of every result, including duplicates.

Constraints

  • 1 <= len(responses) <= 10^4
  • Each response contains a results list and a next_cursor value
  • Each next_cursor is either a string or null
  • Responses are ordered as returned by the Notion API

Function Signature

def collect_notion_results(responses):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output