problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::subarray_product_less_than_k::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int numSubarrayProductLessThanK (vector< int > &nums, int k)
 

详细描述

在文件 leetcode.h2340 行定义.

成员函数说明

◆ numSubarrayProductLessThanK()

int leetcode::subarray_product_less_than_k::Solution::numSubarrayProductLessThanK ( vector< int > &  nums,
int  k 
)
static

在文件 leetcode.cpp6191 行定义.

6191 {
6192 int ans = 0;
6193 int prod = 1;
6194 int i = 0;
6195 for(int j = 0; j < nums.size(); j++) {
6196 prod *= nums[j];
6197 while(i <= j && prod >= k) {
6198 prod /= nums[i];
6199 i++;
6200 }
6201 ans += j - i + 1;
6202 }
6203 return ans;
6204 }

被这些函数引用 leetcode::subarray_product_less_than_k::TEST().


该类的文档由以下文件生成: