标签:height alt 技术 rod http bar span ret color
题目:
解答:
1 class Solution { 2 public: 3 int numSubarrayProductLessThanK(vector<int>& nums, int k) 4 { 5 if (k <= 1) 6 { 7 return 0; 8 } 9 10 int prod = 1; 11 int ans = 0; 12 int left = 0; 13 for (int right = 0; right < nums.size(); right++) 14 { 15 prod *= nums[right]; 16 while (prod >= k) 17 { 18 prod /= nums[left++]; 19 } 20 ans += right - left + 1; 21 } 22 return ans; 23 24 } 25 };
标签:height alt 技术 rod http bar span ret color
原文地址:https://www.cnblogs.com/ocpc/p/12831500.html