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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Build a Spreadsheet Grid
00:00
5 left

Build a Spreadsheet Grid

HardPython

Problem

Build a spreadsheet-like grid with cell editing and formula support, such as =SUM(A1,B1).

Asked in the Technical screen stage. Evaluate cell values with dependencies, using DFS as suggested by the author.

Implement evaluate_spreadsheet(edits). edits is a map from uppercase cell references to either an integer string or a formula in the form =SUM(arg1,arg2,...), where each argument is a cell reference or integer. A missing referenced cell has value 0. Return a map containing every edited cell and its evaluated integer value. Any cell involved in a dependency cycle, or depending on one, must have value "ERROR".

Examples: {"A1":"2","B1":"=SUM(A1,3)"} returns {"A1":2,"B1":5}. {"A1":"=SUM(B1)","B1":"=SUM(A1)"} returns {"A1":"ERROR","B1":"ERROR"}.

Constraints: At most 10,000 edited cells; formulas contain valid syntax and at most 20 arguments.

Constraints

  • At most 10,000 edited cells
  • Cell references use uppercase letters followed by a positive row number
  • Cell contents are integer strings or valid formulas of the form =SUM(arg1,arg2,...)
  • Each formula contains at most 20 arguments
  • A missing referenced cell has value 0

Function Signature

def evaluate_spreadsheet(edits):
Interviewer

Your question is Build a Spreadsheet Grid. 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.