cswork / OAOpen practice workspace

CiscoOA #26

Find Words in Grid

Estimated EasyJudge-ready

Topics (AI-labelled)Strings

For each word, independently determine whether it appears as a contiguous segment of some row or some column of the grid, read either forward or backward. It cannot turn or go diagonally, and matching is case-sensitive.

Input

The input is a JSON array [gridRows,words]. The original had no numeric bounds; this site adds 1≤number of rows, number of columns≤200, with all rows of equal length in Unicode code points; 0≤number of words≤200, each word 1..200 code points, and total word length ≤40000. Characters are arbitrary Unicode scalar values, including whitespace, NUL, and non-BMP characters; lone surrogates are not allowed. The whole JSON is ≤1000000 UTF-8 bytes, and the generator uses ASCII escapes so that control characters are carried intact.

Output

Output Yes or No for each query in order, separated by spaces or newlines; if there are no queries, output an empty line.

Example 1

Input:

[["abc","def"],["cba","ad","ae"]]

Output:

Yes Yes No

Example 2

Input:

[["A a"],["A","a"," "]]

Output:

Yes Yes Yes

Example 3

Input:

[["\ud83d\ude00\u0000"],[]]

Output:

Example notes

The outputs of the three public examples are, in order: Yes Yes No; Yes Yes Yes; empty text. Verified by independent enumeration or direct simulation.

Editorial

Loading solution…