일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- FIT XR
- 10분
- 스탭퍼
- Problem Solving
- 화상영어
- 영어공부
- 파비최
- 쓰릴오브파이트
- English
- realclass
- 매일
- leetcode
- 리얼 클래스
- 30분
- 만화도
- 뭐든
- 읽기
- 영어원서읽기
- 3줄정리
- 괜찮음
- 프로젝트
- 링피트
- 미드시청
- Daily Challenge
- 사이드
- Writing
- 월간
- 개발자
- 잡생각
- 운동
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/minimum-time-to-make-rope-colorful/
Minimum Time to Make Rope Colorful - 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
솔루션을 따라 했는데도 이해가 잘 안됨 =_=;
몇 일 쉬어서 그런듯..?
class Solution:
def minCost(self, colors: str, neededTime: List[int]) -> int:
total_time = 0
i, j = 0, 0
while i < len(neededTime) and j < len(neededTime):
curr_total = 0
curr_max = 0
while j < len(neededTime) and colors[i] == colors[j]:
curr_total += neededTime[j]
curr_max = max(curr_max, neededTime[j])
j += 1
total_time += curr_total - curr_max
i = j
return total_time
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.10.05 |
---|---|
Today's Challenge (0) | 2022.10.04 |
Today's Challenge (0) | 2022.10.02 |
Today's Challenge (0) | 2022.10.01 |
Today's Challenge (0) | 2022.09.30 |
Comments