Amazon | Phone | SDE II | USA

Anonymous User
589
Sep 22, 2024

I have a empty crossword puzzle represented as a 2d matrix. Unavailable squares are marked as "B" and available as "W". A word can be placed horizontally or vertically and can be any length (including 1).

Write a function that tells me how many places I can put words. For each word if you can, also give me their coordinates.

Example:

crossword = [
    ["B", "B", "B", "B", "B"],
    ["B", "W", "W", "B", "B"],
    ["B", "W", "B", "B", "B"],
    ["B", "W", "W", "B", "B"],
    ["B", "B", "B", "B", "B"]
]

Your solution should return 10.
5 of length 1
2 horizontal of length 2
2 vertical of length 2
1 vertical of length 3

Does anyone how to solve this?

Comments (4)