代码仓库:Github | Leetcode solutions @doubleZ0108 from Peking University.
- 解法1(T74% S68%):首先一次遍历统计每个位的数位值出现多少次(可以通过哈希表或bitmaps因为只有数字),再一次遍历判断每一位的数值是否等于哈希表中储存的数字出现计数即可
class Solution:
def digitCount(self, num: str) -> bool:
table = Counter([s for s in num])
for i in range(len(num)):
if int(num[i]) != table[str(i)]:
return False
return True
1302

被折叠的 条评论
为什么被折叠?



