ORIGINAL CODING QUESTION
Shared contiguous glyph block
Return the length of the longest contiguous glyph block occurring in both inputs. Skipping characters is not allowed.
Original exercise · medium. Editorial role relevance does not imply a company has asked this question.
Input and output
n, n glyph integers, m, m glyph integers. Print the requested integer.
Constraints
1 ≤ n,m ≤ 30; each glyph integer is in [0,25].
Example 1
Input
4 0 1 2 3 3 1 2 4
Output
2
The shared block 1,2 has length two.
Example 2
Input
3 0 1 2 2 0 2
Output
1
Only singleton shared blocks qualify.
Explain your approach
Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?
Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.
Hint 1
Track matching suffixes of prefix pairs.
Hint 2
A mismatch resets that suffix to zero.
Hint 3
Keep the largest matching suffix anywhere in the table.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →