Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Build a Translate App UI in Jetpack Compose
00:00
5 left

Build a Translate App UI in Jetpack Compose

MediumPython

Problem

Android coding: using Jetpack Compose, build a UI similar to the Google Translate app home page

Asked in the phone screen (Android coding) stage. Compose UI coding round.

For grading, implement the pure state-building logic that feeds the Compose screen. Given available languages, selected languages, and recent translations, return a render model containing the language bar, swap availability, input area, and recent items. Preserve language order and do not mutate inputs.

Function: build_translate_home_state(languages, source, target, recent)

languages is a non-empty list of strings, source and target are language names, and recent is a list of objects with source_text, translated_text, source, and target. Return a dictionary with keys languages, source, target, can_swap, input_text, and recent.

Constraints

  • 1 <= len(languages) <= 1000
  • Each language name is a non-empty string
  • source and target are strings
  • 0 <= len(recent) <= 1000
  • Each recent item contains source_text, translated_text, source, and target
  • Do not mutate any input list or dictionary

Function Signature

def build_translate_home_state(languages, source, target, recent):
Interviewer

Your question is Build a Translate App UI in Jetpack Compose. 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.