Problem 1:

Problem 2:

Problem statement:
The problem requires identifying the length of the longest self-sufficient substring in a given string S with size n consisting of lowercase letters. Find the longest self-sufficient substring.
Definition of a self-sufficient substring:
Constraints: 1<= n<= 1e5
Output: The length of the longest self-sufficient proper substring. If no such substring exists, return 0.
Example:
S = "amazonservices"
O/p = 11 as "zonservices" is substring of maximum length which satisfy the condition.
Valid substrings are:
"amazon", "services", "ama", "ervice"
Invalid substrings are:
"amazonservices", "amazonservice", "amazons"
You can share your approaches.
Cheers!!