Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Type-Safe Dynamic List Renderer

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

Your question is Type-Safe Dynamic List Renderer. 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

Implement a function that powers a dynamic UI list renderer. Given an array of component descriptors, where each descriptor has a stable id, a type, and a props object, return a render plan that reuses previously rendered components when both type and props are unchanged. The function should output the ordered list of component ids to render and the subset of ids that must be updated.

Constraints

  • 0 <= len(prev), len(next) <= 10^5
  • Each descriptor contains string fields id and type
  • All id values in each input array are unique
  • props is a JSON-like object with primitive values or nested objects/arrays

Function Signature

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