text: function maxLength(arr) {
      /*
          two pointer: left right
          map[all elements in array and index]
          right in map, left = array[index] + 1  
      */
  
      // when array is empty
      if (arr.length === 0) return 0
  
      // init dic
      let map = new Map();
  
      // init two pointer
      let left = 0;
      let right = 0;
  
      // max length
      let res = 1;
  
      // traverse array
      while (left <= right && right < arr.length) {
  
          // find new left
  
          // new element not include
          if (!map.has(arr[right])) {
              res = Math.max(right - left + 1, res);
  
              // save index to map
          }
  
          // right element exist
          else {
              // right element is lefter then left element
              if (map.get(arr[right]) < left) {
                  res = Math.max(right - left + 1, res);
              }
  
              // right element is righter then left element
              else {
                  left = map.get(arr[right]) + 1;
              }
  
          }
  
          // get max length 
  
          // move pointer
          map.set(arr[right], right)
          right++;
  
      }
  
  
      return res;
  }
  
  
  // console.log(maxLength([2, 3, 4, 5]));
  // console.log(maxLength([2, 2, 3, 4, 3]));
  // console.log(maxLength([9]));
  console.log(maxLength([2, 2, 3, 4, 8, 99, 3]));