LeetCode --- 1550. Three Consecutive Odds 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1550. Three Consecutive Odds 解题报告相关的知识,希望对你有一定的参考价值。

Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.

Example 1:

Input: arr = [2,6,4,1]
Output: false
Explanation: There are no three consecutive odds.

Example 2:

Input: arr = [1,2,34,3,4,5,7,23,12]
Output: true
Explanation: [5,7,23] are three consecutive odds.

Constraints:

  • 1 <= arr.length <= 1000
  • 1 <= arr[i] <= 1000

# -*- coding:utf-8 -*-
__author__ = \'yangxin_ryan\'
"""
Solutions:
题意是判断给定的数组中,是否有满足三个连续的奇数,不满足返回False,否则返回True
通过累加计数器的方式计算即可。
"""


class ThreeConsecutiveO

以上是关于LeetCode --- 1550. Three Consecutive Odds 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 1550. 存在连续三个奇数的数组

LeetCode Power of Three

leetcode 326. Power of Three

[LeetCode][JavaScript]Power of Three

[leetcode]326. Power of Three

LeetCode-326. Power of Three