Skip to content

Commit e21855e

Browse files
authored
Create 713. Subarray Product Less Than K
1 parent ccef2d6 commit e21855e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

713. Subarray Product Less Than K

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int numSubarrayProductLessThanK(vector<int>& v, int k) {
4+
int n=v.size();
5+
int ans=0;
6+
for(int i=0;i<n;i++) {
7+
int s=1;
8+
for(int j=i;j<n;j++) {
9+
s=s*v[j];
10+
if(s>=k)
11+
break;
12+
ans++;
13+
}
14+
}
15+
return ans;
16+
}
17+
};

0 commit comments

Comments
 (0)