#include <iostream>

int main() {

    char str[] = "abcabcbb";
    int size = sizeof(str)/sizeof(str[0]);

    int max = 0;
    int len = 0;
    
    int check[256] = {0};
    int start = 0;
    
    for(int i = 0 ; i<size; i++) 
    {

        
        while(check[str[i]] == 1) 
        {
            check[str[start]] = 0;
            start++;

            len--;
        }
        
        len++;
        check[str[i]] = 1;
        
        if(max < len) 
        {
            max = len;
        }
    }

    printf("%d", max);
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: