Add time and space complexity documentation to LongestNonRepetitiveSubstring (#7284)

This commit is contained in:
Mohan E
2026-02-21 18:40:37 +05:30
committed by GitHub
parent 7c38e5acd2
commit 2d443a9991

View File

@@ -13,6 +13,12 @@ final class LongestNonRepetitiveSubstring {
/**
* Finds the length of the longest substring without repeating characters.
*
* Uses the sliding window technique with a HashMap to track
* the last seen index of each character.
*
* Time Complexity: O(n), where n is the length of the input string.
* Space Complexity: O(min(n, m)), where m is the size of the character set.
*
* @param s the input string
* @return the length of the longest non-repetitive substring
*/