일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 미드시청
- 화상영어
- 잡생각
- 스탭퍼
- 운동
- 영어원서읽기
- 월간
- 매일
- Daily Challenge
- 프로젝트
- 30분
- 만화도
- 링피트
- 10분
- realclass
- 파비최
- 3줄정리
- 사이드
- 개발자
- 쓰릴오브파이트
- Problem Solving
- 뭐든
- 괜찮음
- 영어공부
- English
- FIT XR
- 읽기
- 리얼 클래스
- Writing
- leetcode
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.04.11 Today's Challenge 본문
https://leetcode.com/problems/removing-stars-from-a-string/
Removing Stars From a String - LeetCode
Can you solve this real interview question? Removing Stars From a String - You are given a string s, which contains stars *. In one operation, you can: * Choose a star in s. * Remove the closest non-star character to its left, as well as remove the star it
leetcode.com
너무 어렵게 생각한듯..
그냥 stack으로 풀면 되는 문제
class Solution:
def removeStars(self, s: str) -> str:
st = []
for i in range(0, len(s)):
if s[i] == '*':
st.pop()
else:
st.append(s[i])
return ''.join(st)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.04.13 Today's Challenge (0) | 2023.04.13 |
---|---|
2023.04.12 Today's Challenge (0) | 2023.04.12 |
2023.04.10 Today's Challenge (0) | 2023.04.10 |
2023.04.09 Today's Challenge (0) | 2023.04.09 |
2023.04.08 Today's Challenge (0) | 2023.04.08 |
Comments