Amazon | Phone | SDE II | USA
Company: Amazon
Role: SDE II
Interview Stage: Phone Screen
Location: USA
Year: unknown
Original Post Content:
I have an 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 know how to solve this?