当前位置:网站首页>Daily question 1 - force deduction - there are three consecutive arrays of odd numbers
Daily question 1 - force deduction - there are three consecutive arrays of odd numbers
2022-06-29 06:52:00 【Huige who loves programming】
The title comes from Li Kou ——1550. There are three consecutive odd arrays - Power button (LeetCode) (leetcode-cn.com)
Give you an array of integers arr, Please judge whether three consecutive elements in the array are odd : If there is , Please return true ; otherwise , return false .
Example 1:
Input :arr = [2,6,4,1]
Output :false
explain : There is no case where three consecutive elements are odd .
Example 2:Input :arr = [1,2,34,3,4,5,7,23,12]
Output :true
explain : There is a case where three consecutive elements are odd , namely [5,7,23] .
bool threeConsecutiveOdds(int* arr, int arrSize){
int i = 0;
int count = 0;
for(i=0;i<arrSize;i++)
{
if(arr[i] %2 !=0)
{
count++;
if(count == 3)
{
break;
}
}
else
{
count = 0;
}
}
if(count == 3)
{
return true;
}
else
{
return false;
}
}边栏推荐
- 用机器人教育创造新一代生产和服务工具
- [C language] flexible array
- 把多个ROC曲线画在一张图上
- How to change the password after forgetting the MySQL password (the latest version of 2022 detailed tutorial nanny level)
- Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
- JDBC | Chapter 6: simple use of database connection pool
- 2022.02.15 - 240. Lucky number in matrix
- 2022.02.14 - 239. A single element in an ordered array
- flutter配置国内镜像,连接真机
- package.json的所有配置项及其用法,你都熟悉么
猜你喜欢

2022.02.14 - 239. A single element in an ordered array

How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli

RedisTemplate处理hash整数类型的问题解析

Qt 程序打包发布-windeployqt工具

关于DDNS

Move disassembly of exclusive delivery of script (the first time)

MySQL learning notes

Games101 Lecture 10 geometry 1 Notes

How does schedulerx help users solve distributed task scheduling problems?

Hyperledger Fabric 2. X custom smart contract
随机推荐
Output of character pointer to string in C language
Yyds dry goods inventory meituan's two-sided experience, and finally there was a surprise?
Qt 处理图像数据的类区别(QPixmap、QImage、QPicture)
package. Are you familiar with all configuration items and their usage of JSON
QT (x): packaging and deployment
想请教一下,究竟有哪些劵商推荐?在线开户是安全么?
VerilogA - counter
Analysis on the wave of learning robot education for children
分享 10 个 JS Promise 相关的面试题
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
[deep learning] - maze task learning I (to realize the random movement of agents)
多线程工具类 CompletableFuture
How to do the performance pressure test of "Health Code"
How does schedulerx help users solve distributed task scheduling problems?
力扣今日题-324. 摆动排序 II
Teach you how to develop your own NPM package (publish to the NPM official website)
Labor skills courses integrated into steam Education
WDCP accesses all paths that do not exist and jumps to the home page without returning 404
Error: GPG check FAILED Once install MySQL
Mongodb sort function