Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit adfca71

Browse files
author
Navy.Tian
committed
add weekly-contest 382
1 parent 58230c5 commit adfca71

File tree

9 files changed

+56
-5
lines changed

9 files changed

+56
-5
lines changed

‎weekly-contest/122d/p4_3012.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Solution:
88
def minimumCost(self, nums: List[int], k: int, dist: int) -> int:
9-
# TODO
9+
# TODO:
1010
...
1111

1212

‎weekly-contest/379/p4_3003.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Solution:
55
def maxPartitionsAfterOperations(self, s: str, k: int) -> int:
6-
# TODO
6+
# TODO:
77
...
88

99

‎weekly-contest/380/p3_3007.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Solution:
22
def findMaximumNumber(self, k: int, x: int) -> int:
3-
# TODO
3+
# TODO:
44
...
55

66

‎weekly-contest/380/p4_3008.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Solution:
55
def beautifulIndices(self, s: str, a: str, b: str, k: int) -> List[int]:
6-
# TODO
6+
# TODO:
77
...
88

99

‎weekly-contest/381/p4_100213.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Solution:
55
def countOfPairs(self, n: int, x: int, y: int) -> List[int]:
6-
# TODO
6+
# TODO:
77
# distances = {}
88
# for i in range(1, n + 1):
99
# for j in range(i + 1, n + 1):

‎weekly-contest/382/p1_100215.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def countKeyChanges(self, s: str) -> int:
3+
ans = 0
4+
index = 0
5+
s = s.lower()
6+
pre_char = s[0]
7+
while index < len(s):
8+
if s[index] != pre_char:
9+
ans += 1
10+
pre_char = s[index]
11+
index += 1
12+
return ans
13+
14+
15+
if __name__ == "__main__":
16+
assert Solution().countKeyChanges("abc") == 2
17+
assert Solution().countKeyChanges("aAbBcC") == 2
18+
assert Solution().countKeyChanges("AaAaAaaA") == 0

‎weekly-contest/382/p2_100206.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def maximumLength(self, nums: List[int]) -> int:
6+
# TODO:
7+
...
8+
9+
10+
if __name__ == "__main__":
11+
assert Solution().maximumLength(nums=[5, 4, 1, 2, 2]) == 3
12+
assert Solution().maximumLength(nums=[1, 3, 2, 4]) == 1

‎weekly-contest/382/p3_100195.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def flowerGame(self, n: int, m: int) -> int:
3+
return n * m // 2
4+
5+
6+
if __name__ == "__main__":
7+
assert Solution().flowerGame(3, 2) == 3
8+
assert Solution().flowerGame(1, 1) == 0

‎weekly-contest/382/p4_100179.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def minOrAfterOperations(self, nums: List[int], k: int) -> int:
6+
# TODO:
7+
...
8+
9+
10+
if __name__ == "__main__":
11+
assert Solution().minOrAfterOperations(nums=[3, 5, 3, 2, 7], k=2) == 3
12+
assert Solution().minOrAfterOperations(nums=[7, 3, 15, 14, 2, 8], k=4) == 2
13+
assert Solution().minOrAfterOperations(nums=[10, 7, 10, 3, 9, 14, 9, 4], k=1) == 15

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /