给你一个整数数组 arr
,请你判断数组中是否存在连续三个元素都是奇数的情况:如果存在,请返回 true
;否则,返回 false
。
示例一:
1 | 输入:arr = [2,6,4,1] |
示例二:
1 | 输入:arr = [1,2,34,3,4,5,7,23,12] |
提示:
1 <= arr.length <= 1000
1 <= arr[i] <= 1000
解法
解法一:
Java
1 | public boolean threeConsecutiveOdds(int[] arr) { |
解法二:
Java
1 | public boolean threeConsecutiveOdds(int[] arr) { |