Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Build and Test State-Driven Screen

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

Your question is Build and Test State-Driven Screen. 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 small state-driven screen model for a native mobile project. Given a data source that fetches a list of items and a screen controller/view-model that exposes UI state, write a functionally complete implementation that supports idle, loading, success, and error states. The screen should also support retrying after a failed load. Return the final state object after each action so it can be rendered by the native UI layer.

Constraints

  • 1 <= len(actions) <= 10^4
  • Each action is either "load" or "retry"
  • Each response is either the string "error" or a list of 0 to 10^3 strings
  • Total number of returned item strings across all successful responses is at most 10^5

Function Signature

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