统计已测试设备

image-20231210115855304

1
2
3
4
5
6
7
8
9
10
class Solution:
def countTestedDevices(self, batteryPercentages: List[int]) -> int:
res = 0
for i in range(len(batteryPercentages)):
if batteryPercentages[i] > 0:
res += 1
for j in range(i + 1, len(batteryPercentages)):
batteryPercentages[j] = max(0, batteryPercentages[j] - 1)
# print(batteryPercentages)
return res

双模幂运算

image-20231210115921406

1
2
3
4
5
6
7
8
class Solution:
def getGoodIndices(self, variables: List[List[int]], target: int) -> List[int]:
res = []
for i in range(len(variables)):
if ((variables[i][0] ** variables[i][1]) % 10) ** variables[i][2] % variables[i][3] == target:
res.append(i)

return res

统计最大元素出现至少 K 次的子数组

给你一个整数数组 nums 和一个 正整数 k

请你统计有多少满足 「 nums 中的 最大 元素」至少出现 k 次的子数组,并返回满足这一条件的子数组的数目。

子数组是数组中的一个连续元素序列。

image-20231210115737423

统计好分割方案的数目

image-20231210115820635