简单题,直接统计就行
class Solution:
def countPoints(self, rings: str) -> int:
n = len(rings) // 2
cnt = [[0, 0, 0] for _ in range(10)]
for i in range(0, 2*n, 2):
if rings[i] == "R":
cnt[int(rings[i + 1])][0] = 1
if rings[i] == "G":
cnt[int(rings[i + 1])][1] = 1
if rings[i] == "B":
cnt[int(rings[i + 1])][2] = 1
ans = 0
for i in cnt:
if sum(i) == 3:
ans += 1
return ans