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 {number[]} nums
   * @param {number} k
   * @return {number}
   */
  
  var minimumDifference = function(nums, k) {
      nums.sort((a, b) => a - b);
      var res = Number.POSITIVE_INFINITY;
      for (var i = 0; i + k <= nums.length; i++) {
          var a = nums[i], b = nums[i + k - 1];
          res = Math.min(res, b - a);
          if (res == 0) {
              return res;
          }
      }
      return res;
  };
  