当前位置:网站首页>Sword finger offer II 009. subarray with product less than k
Sword finger offer II 009. subarray with product less than k
2022-07-26 15:19:00 【Mr Gao】
The finger of the sword Offer II 009. The product is less than K Subarray
Given an array of positive integers nums And integer k , Please find out that the product in the array is less than k The number of successive subarrays of .
Example 1:
Input : nums = [10,5,2,6], k = 100
Output : 8
explain : 8 The product is less than 100 The subarrays of are : [10], [5], [2], [6], [10,5], [5,2], [2,6], [5,2,6].
It should be noted that [10,5,2] It's not that the product is less than 100 Subarray .
Example 2:
Input : nums = [1,2,3], k = 0
Output : 0
The solution code is as follows :
int numSubarrayProductLessThanK(int* nums, int numsSize, int k){
int count=0;
int i,j;
for(i=0;i<numsSize;i++){
if(nums[i]<k){
count++;
}
int sum=nums[i];
for(j=i+1;j<numsSize;j++){
sum=sum*nums[j];
if(sum<k){
count++;
}
else{
break;
}
}
}
return count;
}
边栏推荐
- About the selection of industrial control gateway IOT serial port to WiFi module and serial port to network port module
- Ner of NLP: Exploration and practice of product title attribute recognition
- MYSQL 命令大全
- 示波器的使用
- 大学论文格式怎么写?
- 哪里有写毕业论文需要的外文文献?
- Continuous integration (II) introduction to the basic use of Jenkins
- USB转串口参数配置功能
- Cs224w (Figure machine learning) 2021 winter course learning notes 5
- 【5分钟Paper】Pointer Network指针网络
猜你喜欢

What are the skills and methods of searching foreign literature

持续集成(二)Jenkins基本使用介绍

In the changing era of equipment manufacturing industry, how can SCM supply chain management system enable equipment manufacturing enterprises to transform and upgrade

C # set different text watermarks for each page of word

Deep Packet Inspection Using Quotient Filter论文总结

固态硬盘对游戏运行的帮助有多少

Yifang biological fell 16% on the first day of listing: the company's market value was 8.8 billion, and Hillhouse and Lilly were shareholders

Parallel d-Pipeline: A Cuckoo Hashing Implementation for Increased Throughput论文总结

If food manufacturing enterprises want to realize intelligent and collaborative supplier management, it is enough to choose SRM supplier system

How to query foreign literature?
随机推荐
oss删除当前时间前两天的所有文件
解决Typora图片显示不出来问题
最详细的专利申请教程,教你如何申请专利
OpenGL学习日记2——着色器
Continuous integration (I) brief introduction to basic concepts
About the selection of industrial control gateway IOT serial port to WiFi module and serial port to network port module
R语言使用lm函数构建带交互项的多元回归模型、使用step函数构建逐步回归模型筛选预测变量的最佳子集(step regression)
Vs add settings for author information and time information
【LeetCode每日一题】——268.丢失的数字
In the changing era of equipment manufacturing industry, how can SCM supply chain management system enable equipment manufacturing enterprises to transform and upgrade
Yifang biological fell 16% on the first day of listing: the company's market value was 8.8 billion, and Hillhouse and Lilly were shareholders
How do college students apply for utility model patents?
数据挖掘之数据预处理
VP video structured framework
Bluetooth ble4.0-hm-10 device pairing Guide
Data preprocessing of data mining
[leetcode daily question] - 268. Missing numbers
楚环科技深交所上市:市值27亿 民生证券是股东
双屏协作效率翻倍 灵耀X双屏Pro引领双屏科技新潮流
Sharkteam releases Web3 security situational awareness report in the second quarter of 2022