일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- leetcode
- 영어원서읽기
- 10분
- 프로젝트
- 30분
- 영어공부
- 만화도
- Daily Challenge
- 스탭퍼
- FIT XR
- realclass
- 뭐든
- Problem Solving
- 리얼 클래스
- 잡생각
- 매일
- 3줄정리
- 운동
- 화상영어
- 개발자
- 괜찮음
- 파비최
- Writing
- 사이드
- 월간
- 미드시청
- 쓰릴오브파이트
- 링피트
- 읽기
- English
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.09.27 Today's Challenge 본문
https://leetcode.com/problems/decoded-string-at-index/
LeetCode - The World's Leading Online Programming Learning Platform
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
역시나 스택을 이용하는 문제!
class Solution:
def decodeAtIndex(self, s: str, k: int) -> str:
size = 0
for i in range(len(s)):
if s[i].isdigit():
size *= int(s[i])
continue
size += 1
for i in range(len(s)-1, -1, -1):
k = k % size
if k == 0 and s[i].isalpha():
return s[i]
if s[i].isdigit():
size //= int(s[i])
continue
size -= 1
return ""
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.09.29 Today's Challenge (0) | 2023.09.29 |
---|---|
2023.09.28 Today's Challenge (0) | 2023.09.28 |
2023.09.26 Today's Challenge (0) | 2023.09.26 |
2023.09.25 Today's Challenge (0) | 2023.09.25 |
2023.09.24 Today's Challenge (0) | 2023.09.24 |
Comments