DatabricksOA #13
Check Pattern Presence
Estimated EasyJudge-ready
Topics (AI-labelled)Strings
You are given a digit string panel and several code strings. Split each code into index and pattern, with the index part having length 1 through len(code)-1 in order; parse index as a decimal integer (leading zeros do not affect the value). If the contiguous segment of panel starting at that 0-based index exactly equals pattern, the result of that split is pattern; otherwise it is not found. Output the results in code order, then in order of split length.
Standard input/output and this site's supplementary ranges follow this problem's description.
Input
The first line contains panel (1..1000 ASCII digits); the second line contains c (1≤c≤100), followed by c lines, each an ASCII digit string code, with 2≤len(code)≤100 and total code characters ≤5000. The above upper bounds on c and code are site supplements that keep the output from becoming too large. Each index and pattern has at least one digit.
Output
Output one line per split: pattern if it matches, otherwise not found. The order follows the input order of code, and within each code, increasing split length.
Example 1
Input:
2311453915
2
0211
639
Output:
not found
11
not found
39
not found
Example 2
Input:
00000
2
000
101
Output:
00
0
not found
not found
Example 3
Input:
7
1
07
Output:
7
Editorial
Loading solution…