Available question text
Given a string s (|s| ≤ 10^5), return the longest non-empty proper prefix that is also a suffix (i.e., the longest "border") of s. This is typically solved by computing the KMP prefix-function (LPS) or using Z-function/rolling hashes to find the maximum matching border efficiently.
Related questions
Continue with questions that share topics or the same question type.
- Find the Length of the Longest Common Prefix
Coding
- Longest Common Prefix
Coding · Array · String · Trie
- Longest Common Prefix After at Most One Removal
Coding
- Longest Common Prefix Between Adjacent Strings After Removals
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1392. Longest Happy Prefix
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source