Skip to content
Advertisement

Given a string s, find the length of the longest substring without repeating characters

Example Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. I tried writing this but if condition is never being exceuted. I am not able to figure out the reason.

JavaScript

Advertisement

Answer

This is the same algorithm as described by danhuong, simply written with a recursive call and no mutable variables.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement