Code RoomCrossword puzzle solver
HardPrep Room Coding #4915

Crossword puzzle solver

CodingAlgorithms & data structuresMid–Staff~40 min

A puzzle tool fills a fixed crossword frame. grid_rows draws the frame one row at a time, every row the same width, where a hash marks a blocked square and a dot marks a square to be filled. A slot is a run of two or more dots bounded by a wall or a blocked square, read across a row or down a column, and every dot lies in at least one slot. Each slot takes one word from words, a word is used at most once, the word length must match the slot length, and two crossing slots must agree on the letter they share. The words are distinct and may outnumber the slots. Return the finished frame as its rows, and when several fillings work return the one whose rows, joined in order, come first alphabetically. A frame with no slots is already finished, so return it unchanged. Return an empty list when no filling works and when the frame has no rows. The frame is at most 5 by 5 and words holds at most 12 entries.

Implement
fill_crossword_slots(grid_rows: list[str], words: list[str]) → list[str]
Examples
in[["..",".."],["at","no","an","to"]]out["an","to"]
in[["...",".#.","..."],["cat","cow","wet","tot"]]out["cat","o#o","wet"]
in[["...."],["abcd","abce"]]out["abcd"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 40 min
InputExpectedGot
[["..",".."],["at","no","an","to"]]["an","to"]not run yetsample
[["...",".#.","..."],["cat","cow","wet","tot"]]["cat","o#o","wet"]not run yetsample
[["...."],["abcd","abce"]]["abcd"]not run yetsample