Longest Border
A border of S is a string that is both a proper prefix and a proper suffix of S. Print the length of the longest border (0 if none).
Input: one line with a lowercase string.
Output: the longest border length.
Constraints:
- 1 ≤ |S| ≤ 104
Sample Tests
Input 1
abcab
Output 1
2
Input 2
aaaa
Output 2
3
Discussion (opens after you solve — no spoilers before)
No comments yet.