본문 바로가기
Leetcode

844. Backspace String Compare

by YGSEO 2020. 7. 21.
728x90

다른 사람 솔루션

class Solution:
    def backspaceCompare(self, S: str, T: str) -> bool:
        
        ans = ''
        ans_2 = ''
        for i in S:
            if i == '#':
                ans = ans[:-1]
            else:
                ans += i
        
        for i in T:
            if i == '#':
                ans_2 = ans_2[:-1]
            else:
                ans_2 += i
        return ans == ans_2

list가 아닌 string을 활용해서 stack

728x90

'Leetcode' 카테고리의 다른 글

921. Minimum Add to Make Parentheses Valid  (0) 2020.07.22
20. Valid Parentheses  (0) 2020.07.21
682. Baseball Game  (0) 2020.07.19
496. Next Greater Element I  (0) 2020.07.06
1047. Remove All Adjacent Duplicates In String  (0) 2020.07.05

댓글