今天第二题测试了很多例子都通过了,但是还是不能ac,大神们帮看下什么原因
class Solution: def solve(self, string): # write code here start = 0 while True: if len(string) <= 1: return string if len(string) == 2 and string != "00" and string != "11": return string if string[start:start + 2] == "00": string = string[:start] + "1" + string[start + 2:] start = start - 1 if start - 1 > 0 else 0 elif string[start:start + 2] == "11": string = string[:start] + string[start + 2:] else: start += 1 if start == len(string) - 1: return string
全部评论
(0) 回帖