LeetCode #3 [Longest Substring Without Repeating Characters] In C Language Solutions

Subscribers:
1,050
Published on ● Video Link: https://www.youtube.com/watch?v=6GTvs7V_o0g



Duration: 1:00
23 views
1


LeetCode #3 [Longest Substring Without Repeating Characters] In C Language Solutions

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


Solution:
This solution works by iterating over the input string and keeping track of the current substring we are building. It uses an array to keep track of which characters we have seen in the current substring, and updates the length of the substring as necessary. When we encounter a character that we have already seen in the current substring, we start a new substring at the next character in the input string and update the maximum substring length if necessary. At the end of the loop, we return the length of the longest substring we found.