text: // Hi, I'm Yanzhan. I'm interested in all kinds of algorithmic problems. Also, I'm fascinated with javascript. If you want to learn more about programming problems and javascript, please visit my Youtube Channel (https://www.youtube.com/channel/UCDkz-__gl3frqLexukpG0DA?view_as=subscriber), Twitter Account (https://twitter.com/YangYanzhan), GitHub Repo (https://github.com/yangyanzhan/code-camp) or HomePage (https://yanzhan.site/).
  
  // 开始分析
  // 1. 按照要求执行即可。
  // 结束分析
  
  // 开始编码
  
  /**
   * @param {string} s
   * @return {number}
   */
  
  var firstUniqChar = function(s) {
      var map = {};
      for (var i = 0; i < s.length; i++) {
          var ch = s[i];
          if (map[ch] === undefined) {
              map[ch] = [i, 1];
          } else {
              map[ch][1]++;
          }
      }
      var best = Number.POSITIVE_INFINITY;
      for (var key in map) {
          if (map[key][1] == 1) {
              if (map[key][0] < best) {
                  best = map[key][0];
              }
          }
      }
      return best == Number.POSITIVE_INFINITY ? -1 : best;
  };
  