Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Responsive Dashboard Layout
00:00
5 left

Responsive Dashboard Layout

HardPython

Problem

Build a responsive layout for a dashboard application.

Implement the layout algorithm that selects a column count from responsive breakpoints and places widgets in input order using the earliest available grid position. Each widget has an identifier, column span, and row span.

Input: a widget list, viewport width, and breakpoint configurations. Output: widget positions containing row, column, rowSpan, and colSpan; spans larger than the active column count must be clamped.

Constraints

  • 0 <= len(widgets) <= 1000
  • Each widget contains a unique string id, a positive integer span, and a positive integer height
  • Each breakpoint contains a nonnegative integer minWidth and a positive integer columns
  • breakpoints contains at least one entry with minWidth <= viewport_width
  • Breakpoints have distinct minWidth values
  • Widgets must be placed in input order using the earliest row-major position

Function Signature

def layout_dashboard(widgets, viewport_width, breakpoints):
Interviewer

Your question is Responsive Dashboard Layout. 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
Sign up free to run your codeLog inLn 2
Run your code to see test output here.