摘要:
例子: valid_parentheses('i(hi)()') == True valid_parentheses('hi())(') == False valid_parentheses('') == True valid_parentheses('())(())') == False 实现: 阅读全文
摘要:
通过对相邻的字符分组实现: def run_length_encoding(seq): from itertools import groupby cc = [[sum(1 for _ in g), c] for c, g in groupby(seq)] print(cc) return cc c 阅读全文