# 第一题 01数列 AC

s.length < 1000

solution

```class Solution:
def minOperations(self, s: str) -> int:
def f(s, ch):
cnt = 0
for i in range(len(s) - 1):
if s[i] != ch:
cnt += 1
s[i + 1] = ch
s[i] = ch
return cnt if s[-1] == ch else cnt + 1

return min(f(list(s), "0"), f(list(s), "1"))
print(Solution().minOperations("1001101"))```

## 第二题 子数组 AC

a.length ≤ 100000

0 < x < a.length

solution

```class Solution:
def getSubarrayNum(self, a: List[int], k: int) -> int:
# 定义dp[i] 为以i结尾的满足题意的子数组数量
# [5,2,3,50,4],2
mod = 10 ** 9 + 7

def get(x, base):
res = 0
while x % base == 0:
res += 1
x //= base
return res

n = len(a)
dp = [0] * (n + 1)
pre = [(0, 0)]
left = 0
for x in a:
t1, t2 = pre[-1]
pre.append((get(x, 2) + t1, get(x, 5) + t2))
for i in range(1, n + 1):
dp[i] += dp[i - 1]
while min(pre[i][1] - pre[left][1], pre[i][0] - pre[left][0]) >= k:
dp[i] += 1
left += 1
# print(dp)
return sum(dp) % mod

print(Solution().getSubarrayNum([5, 2, 3, 50, 4], 2))```

## 第三题 矩阵 15%

2 ≤ n, m, x ≤ 1e9

1 + 1 + 6

solution

## 总结

#腾讯音乐##笔试##23届秋招笔面经##腾讯音乐23秋招笔试好难啊，麻了#

8 9 评论