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} target
   * @return {number}
   */
  
  var purchasePlans = function(nums, target) {
      var base = Math.pow(10, 9) + 7;
      var res = 0;
      nums.sort(function(a, b) {
          return (+a) - (+b);
      });
      var i = 0, j = nums.length - 1;
      while (i < j) {
          var sum = nums[i] + nums[j];
          if (sum > target) {
              j--;
          } else {
              res += j - i;
              res %= base;
              i++;
          }
      }
      return res;
  };
  