Skip to content

Commit 6d75a1f

Browse files
committed
2020-08-23
1 parent 0fb1fea commit 6d75a1f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution(object):
2+
def threeConsecutiveOdds(self, arr):
3+
"""
4+
:type arr: List[int]
5+
:rtype: bool
6+
"""
7+
l = 0
8+
for num in arr:
9+
if num % 2:
10+
l += 1
11+
if l == 3:
12+
return True
13+
else:
14+
l = 0
15+
return False
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution(object):
2+
def minOperations(self, n):
3+
"""
4+
:type n: int
5+
:rtype: int
6+
"""
7+
k = n // 2
8+
if n % 2:
9+
return 2 * k + k * (k - 1) // 2 * 2
10+
else:
11+
return 1 * k + k * (k - 1) // 2 * 2
12+

0 commit comments

Comments
 (0)