Word Search
InterviewTime limit1sMemory limit256 MB
Find each listed word in the letter grid in any of eight directions and output leftover letters, or report missing or ambiguous placements.
- Level
Medium5 of 10
- Topics
- String matching, Matrix, Brute force
- Solved
- No attempts yet
Problem
Given a letter grid and a word list, every word must appear in one of eight directions. If any word is missing, print no solution. If any word has more than one distinct placement, print ambiguous. Otherwise print the unmarked letters in row-major order, or empty solution if none remain.
Input
The first line contains the number of test cases. Each test gives , , , the grid, and words.
Output
For each test case, print the solution string or one of the three special answers.