Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Complete Shape Grid Rows Columns

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

Your question is Complete Shape Grid Rows Columns. 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

Given an n x n grid of strings representing shapes, fill every empty cell so that each row and each column contains every shape exactly once. Empty cells are marked with ".". You are also given a list shapes of length n containing the allowed distinct shape names. Return the completed grid. You may assume the input always has a unique valid solution.

Constraints

  • 1 <= n <= 6
  • grid.length == n and grid[i].length == n
  • shapes.length == n, and all shapes are distinct strings
  • Each non-empty cell is either "." or one of the strings in shapes
  • The input has exactly one valid completion

Function Signature

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