longest substring without repeating characters

Solutions on MaxInterview for longest substring without repeating characters by the best coders in the world

showing results for - "longest substring without repeating characters"
Bastian
12 May 2016
1#include <bits/stdc++.h>
2
3using namespace std;
4
5int main()
6{
7    string s;
8    cin>>s;
9    int l=s.length();
10    map<char,int>mp;
11    int mx=INT_MIN;
12    int i=0;
13    int j=0;
14    while(j<l)
15    {
16        mp[s[j]]++;
17        if(int(mp.size())<j-i+1)
18        {
19          while(int(mp.size())<j-i+1)
20          {
21              mp.erase(s[i]);
22              i++;
23          }
24          j++;
25        }
26        else if(int(mp.size())==j-i+1)
27        {
28            mx=max(mx,j-i+1);
29            j++;
30        }
31    }
32    cout<<mx;
33    return 0;
34}
35
queries leading to this page
given a string s 2c find the length of the longest sub string without repeating characters longest substring without repeating characterslongest substring without repeating characters 283 29find longest substring with repeating characterslongest substring without repeating characters practice geeksforgeekssolution to longest substring without repeating characters 2fsolution 2flongest substring with at least k repeating characterslength of the longest substring without repeating characterslongest substring with k repeating characterslongest substring with repeating characterslongest substring with without repeating characters gfg practice longest substring without repeating characterslargest substring without repeating characterslongest subsequence without repeating characterslongest substring without repeating characters leetcondefind longest substring with no repeating charactersfind the length of the longest substring without repeating characters longest substring without unique characterslongest non repeating substringfind the longest substring without repeating characterswrite a function to find the longest substring with non repeating characters from a given string longest substring without repeating characterslongest common substring without repeating characterslongest substring without repeating characters what it means3 longest substring without repeating characters3 longest substring without repeating charactersfind longest substring without repeatinglongest substring without repeating cahractersrint longest substring without repeating characterslength of the longest substring without repeating characters longest repeating substring in a stringfind the longest substring without repeating characters in java longest substring without repeating characters javawrite a function which 2c given a string 2c finds the length of the longest substring without repeating charactersgiven a string s 2c find the length of the longest substring without repeating characters example 1 3amaximum substring without repeating characterslongest substring without repeating characters solution longest substring without repeating characterslongest substring without repeating characters javalongest substring without repeatinglongest substring without repeating characters longest substring without repeating characters is asked inlongest substring without repeating characters hackerranklongest substring without repeating characters 28 2fproblemslongest substring without repeatmaximum repeating substringfunction to find longest substring in a given a string without repeating characters longest substring without repeating characters aaditya verma9 8 longest substring without repeating charactershow do you find the length of the longest substring without repeating characters 3flongest substring with no repeating characters 6 longest substring without repeatlongest repeating character substringlongest substring without repeating characters gfglongest non repeating substringlongest substring without repeating characters in javalongest substring without repetating characterlongest substring without repeating characters print practicefind longest substring without repeating charactersfind longest substring in a given string without repeating charactersgiven a string s 2c find the length of the longest substring without repeating characterslongest substring with without repeating characters problemcode for longest substring with no repeating characters 3fthe longest substring with non repeating characterslongest substring with without repeating charactersgiven a string c2 a0s 2c find the length of the longest substring without repeating characters find the longest substring with non repeating characterslongest substring without repeating characters in jsgiven a string s find the length of the longest substring without repeating charactersmaximum length substring repeating characterlongest substring with no repeating characterswrite a function that takes a string s and returns the length of the longest substring without repeating charactersfind longest substring without repeating characters javagiven a string s 2c find the length of the longest substring without repeating characters longest substring with non repeating characterslongest string without repeating charactersgiven a string 2c find the length of the longest substring without repeating characters just return the length of the substring 2c not the substring itself longest substring withut repeating characterslongest substring without repeating characterlength of longest substring without repeating characters6 longest substring without repeatlongest subsequence without repeating characters algorithmlongest substring without repeating characters gfg practiceprogram to find longest substring without repeating characterslength of longest non repeating substringlongest substring without repeating characters solution geeksforgeeksfind the length of the longest substring without repeating characterslongest substring with no duplicate charactersind length of the longest substring of a given string without repeating characters longest substring without repeating characters