Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Describe how you would implement an infinite scrolling past orders page, including data...
00:00
5 left

Describe how you would implement an infinite scrolling past orders page, including data...

MediumPython

Problem

Build a 'My Orders' page showing past orders with infinite scrolling that fetches older orders

Asked in the tech 1 stage. Reported follow-ups included caching scroll position and pagination.

Implement merge_order_pages(pages). pages is a list of fetched pages in newest-to-oldest order. Each page contains order dictionaries with an id and integer created_at timestamp, and may overlap the previous page. Return one list containing each order ID once, sorted from newest to oldest. If the same ID appears more than once, keep its first occurrence.

Constraints

  • 1 <= total orders across pages <= 10^4
  • Each order contains an ID and an integer created_at timestamp
  • Pages are fetched in newest-to-oldest order
  • An order ID may appear in multiple pages

Function Signature

def merge_order_pages(pages):
Interviewer

Your question is Describe how you would implement an infinite scrolling past orders page, including data.... Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.