2020 第 17 周 LeetCode 记录

Yiran at 
1417. Reformat The String 链接到标题 重新格式化字符串,使得字母与数字交叉连接,先分别找出字母与数据,使用 zip_longest 来生成交叉后的元组,然后拼接得到目标字符串。class Solution: def reformat(self, s: str) -> str: a=re.findall(r'\d',s) b=re.findall(r'[a-z]',s) if abs(len(a)-len(b))>1: return '' a,b=sorted([a,b],key=len) return ''.join(map(''.join,itertools.zip……