일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 괜찮음
- 3줄정리
- 만화도
- Problem Solving
- 미드시청
- 화상영어
- 영어원서읽기
- 영어공부
- realclass
- FIT XR
- 사이드
- 링피트
- Daily Challenge
- 매일
- 파비최
- 리얼 클래스
- 프로젝트
- 쓰릴오브파이트
- 월간
- Writing
- 읽기
- 뭐든
- 스탭퍼
- 개발자
- 30분
- leetcode
- English
- 10분
- 잡생각
- 운동
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/backspace-string-compare/
Backspace String Compare - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
처음엔 뭔 문제여.. 했는데 그냥 리스트로 구현하면 되는 거였음.
다른 사람의 풀이를 보니 @staticmethod 어노테이션 써서 구현하는 거 같긴 한데.. 크게 차이는 없을 듯?
class Solution:
def backspaceCompare(self, s: str, t: str) -> bool:
ss, tt = [], []
for i in range(len(s)):
if s[i] != '#':
ss.append(s[i])
continue
if ss:
ss.pop()
for i in range(len(t)):
if t[i] != '#':
tt.append(t[i])
continue
if tt:
tt.pop()
return ss == tt
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.05.03 |
---|---|
Today's Challenge (0) | 2022.05.02 |
Today's Challenge (0) | 2022.04.30 |
Today's Challenge (0) | 2022.04.29 |
Today's Challenge (0) | 2022.04.28 |
Comments