From 2d443a9991f7a80f1ab6bca437d1b953f7d05420 Mon Sep 17 00:00:00 2001 From: Mohan E <777emohan@gmail.com> Date: Sat, 21 Feb 2026 18:40:37 +0530 Subject: [PATCH] Add time and space complexity documentation to LongestNonRepetitiveSubstring (#7284) --- .../strings/LongestNonRepetitiveSubstring.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/thealgorithms/strings/LongestNonRepetitiveSubstring.java b/src/main/java/com/thealgorithms/strings/LongestNonRepetitiveSubstring.java index 6808cd506..51e8dc6b0 100644 --- a/src/main/java/com/thealgorithms/strings/LongestNonRepetitiveSubstring.java +++ b/src/main/java/com/thealgorithms/strings/LongestNonRepetitiveSubstring.java @@ -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 */