Skip to content

Commit 2d443a9

Browse files
authored
Add time and space complexity documentation to LongestNonRepetitiveSubstring (#7284)
1 parent 7c38e5a commit 2d443a9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/thealgorithms/strings/LongestNonRepetitiveSubstring.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ private LongestNonRepetitiveSubstring() {
1313
/**
1414
* Finds the length of the longest substring without repeating characters.
1515
*
16+
* Uses the sliding window technique with a HashMap to track
17+
* the last seen index of each character.
18+
*
19+
* Time Complexity: O(n), where n is the length of the input string.
20+
* Space Complexity: O(min(n, m)), where m is the size of the character set.
21+
*
1622
* @param s the input string
1723
* @return the length of the longest non-repetitive substring
1824
*/

0 commit comments

Comments
 (0)