无重复字符的最长子串

(1)

lengthOfLongestSubstring(s){
      let arr = s.split('');
      let nums = [];
      let len = arr.length;
      let resMax = 0;
      let index = 0;
      while(index < len){
        let max = 0;
        for(let i = 0; i < arr.length; i++){
          if(nums.indexOf(arr[i]) === -1){   // nums中不包含arr[i]
            nums.push(arr[i]);
            max = nums.length > max ? nums.length : max;
          }
          else{
            nums = [];
            break;
          }
        }
        resMax = max > resMax ? max : resMax;
        arr.shift();
        index++;
      }
      return resMax;
    }

(2)