Google 2024-March | Hard CP | KMP Algorithm & LPS Arrays
Google · Question · Posted Jun 2026
Question 1: The Secret Password Problem Statement You are given a single string S. You need to find the longest contiguous substring of S that satisfies ALL THREE of the following conditions simultaneously: It is a Prefix of S. It is a Suffix of S. It appears at least once entirely in the Middle of S (meaning it is not just the exact prefix or exact suffix overlapping). If no such substring exists, you must print exactly Just a legend. ...
The full answer & interview discussion are available to premium members.
Log in Create a free account