Open ji-0630 opened 1 year ago
def solution(s):
i = 0
while len(s) > i+1:
if s[i] == s[i+1]:
s = s[:i]+s[i+2:]
i=0
else:
i += 1
if len(s) == 0:
return 1
else:
return 0
def solution(s):
i = 0
while len(s)-1 > i:
if s[i] == s[i+1]:
s = s[:i]+s[i+2:]
i = max(0, i-1)
else:
i += 1
if len(s) == 0:
return 1
else:
return 0
def solution(s):
tmp = []
for i in s:
if len(tmp) == 0:
tmp.append(i)
else:
if tmp[-1] == i:
tmp.pop()
else:
tmp.append(i)
if len(tmp) == 0:
return 1
else:
return 0
문제 설명