ORIGINAL CODING QUESTION
Longest unrepeated glyph window
Return the length of the longest contiguous glyph sequence with no repeated glyph.
Original exercise · medium. Editorial role relevance does not imply a company has asked this question.
Input and output
n, then n integer values. Print one integer as described.
Constraints
1 ≤ n ≤ 30; each glyph is an integer in [0,25]. Equal integers mean equal characters.
Example 1
Input
5 0 1 0 2 3
Output
4
The span 1,0,2,3 has length four.
Example 2
Input
3 1 1 1
Output
1
Only singleton windows 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
A repeat forces the left boundary beyond the earlier occurrence.
Hint 2
Remember the last position of each glyph.
Hint 3
The left boundary must never move backward.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →