Skip to content

Commit b80c428

Browse files
test(strings, longest_self_contained_substring): doc tests
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 61fada7 commit b80c428

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pystrings/longest_self_contained_substring/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ def longest_self_contained_substring(s: str) -> int:
1111
Returns:
1212
int: The length of the longest self-contained substring, or -1 if no such substring exists.
1313
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).
1425
"""
1526
n = len(s)
1627

0 commit comments

Comments
 (0)