share my javaScript solution,i think it is  easy  to understand
```\nvar lengthOfLongestSubstring = function (s) {\n    var max=0,\n        theSub=\'\'\n    for(var i=0;i=0){  \n         theSub= theSub.substring(idx+1) \n   
```\nvar lengthOfLongestSubstring = function (s) {\n    var max=0,\n        theSub=\'\'\n    for(var i=0;i<s.length;i++){\n        const idx=theSub.indexOf(s[i])\n        theSub+=s[i]\n        if(idx>=0){  \n         theSub= theSub.substring(idx+1) \n        }\n        if(theSub.length>max){\n            max=theSub.length\n        }\n    }\n    return max\n}\n\t
['JavaScript']