We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 61fada7 commit b80c428Copy full SHA for b80c428
pystrings/longest_self_contained_substring/__init__.py
@@ -11,6 +11,17 @@ def longest_self_contained_substring(s: str) -> int:
11
Returns:
12
int: The length of the longest self-contained substring, or -1 if no such substring exists.
13
14
+ Examples:
15
+ >>> longest_self_contained_substring("xyyx")
16
+ 2
17
+ >>> longest_self_contained_substring("xyxy")
18
+ -1
19
+ >>> longest_self_contained_substring("abacd")
20
+ 4
21
+
22
+ Note:
23
+ This implementation uses a brute-force approach with O(n³) time complexity.
24
+ For better performance, consider using max_substring_length() which runs in O(n).
25
"""
26
n = len(s)
27
0 commit comments