Problem · String
Find the Longest Isolated Substring Length
Learn this problemProblem statement
The task is to determine the length of the longest isolated proper substring within a given string. An isolated proper substring must satisfy the following conditions:
- The substring is not the entire given string
inputString. - No character within the substring appears anywhere outside the substring.
Given a string inputString of length n, determine the length of its longest isolated proper substring. If no such substring exists, return 0.
Function
findLongestIsolatedSubstringLength(s: String) → int
Implement the function findLongestIsolatedSubstringLength in the editor.
The function takes the following parameter:
String inputString: the string to analyze
Returns
int: the length of the longest isolated proper substring
Examples
Example 1
s = "abcba"return = 0
A new test case added on 03-01-2025 for your testing convenience :)
The source said the expected output should be 3 -
"abcba output should be : 3 (the substring will be bcb). but expected output is 0."
Example 2
s = "amazonservices"return = 11
(Image updated on 2025-02-02)
The longest self-sufficient proper substring is "zonservices" which has a length of 11.
Constraints
sconsists of lowercase letters.1 ≤ n ≤ 10^5
More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026