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
Tetris Module Fall Simulation
00:00
5 left

Tetris Module Fall Simulation

MediumPython

Problem

Simulate Tetris: determine how far a falling module can go when blocked by blocks below.

Implement drop_distance(board, module, row, col). board is a list of equal-length strings, where # is occupied and . is empty. module contains relative [row, col] cells, and (row, col) is its initial top-left anchor. Return the greatest nonnegative number of rows the module can move downward without leaving the board or overlapping a block. If its initial placement is invalid, return 0.

Constraints

  • 1 <= len(board) <= 100
  • 1 <= len(board[0]) <= 100
  • All board rows have the same length
  • 1 <= len(module) <= 100
  • Each module coordinate is a pair of integers
  • The module does not contain duplicate relative coordinates

Function Signature

def drop_distance(board, module, row, col):
Interviewer

Your question is Tetris Module Fall Simulation. 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.
Code
Sign up free to run your codeLog inLn 2
Run your code to see test output here.