Description
Solutions
Find the Longest Isolated Substring Length
π©βπ NEW GRADπRELATED PROBLEMS
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 Description
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
Example 1:
Input: s = "abcba"
Output: 0
Explanation: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:
Input: s = "amazonservices"
Output: 11
Explanation:(Image updated on 2025-02-02) The longest self-sufficient proper substring is "zonservices" which has a length of 11.
Constraints:
s
consists of lowercase letters.1 ≤ n ≤ 10^5


Related Problems
Testcase
Result
Case 1
input:
output: