diff --git a/notes/面试总结.md b/notes/面试总结.md index 06298c75..96728367 100644 --- a/notes/面试总结.md +++ b/notes/面试总结.md @@ -1016,6 +1016,40 @@ private void initDigitSum() { } ``` +```python +# -*- coding:utf-8 -*- +class Solution: + def __init__(self): + self.acc = 0 + + def movingCount(self, threshold, rows, cols): + # write code here + self.threshold = threshold + self.rows = rows + self.cols = cols + self.board = [[0 for _ in range(cols)] for _ in range(rows)] + + self.traverse(0,0) + return self.acc + + def block(self, r, c): + s = sum(map(int,str(r)+str(c))) + return s>self.threshold + + def traverse(self, r, c): + if not (0<=r