题目:
js-最长不含重复字符的子字符串_子字符串
解答:

/**
 * @param {string} s
 * @return {number}
 */var lengthOfLongestSubstring = function (s) {
  const set = new Set();
  let i = 0,j = 0,maxLength = 0;
  if (s.length === 0) {return 0;
  }
  for (i; i < s.length; i++) {if (!set.has(s[i])) {  set.add(s[i]);  maxLength = Math.max(maxLength, set.size);} else {  while (set.has(s[i])) {set.delete(s[j]);j++;  }  set.add(s[i]);}
  }
  return maxLength;};// 思路:利用i和j两个指针,利用set.has() 方法来看对应的值value是否存在Set对象中。