You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discussion was converted from issue #38 on September 15, 2026 11:01.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time/
Problem Summary
주어진 시간 안에 도착까지 갈 수 있는 최소의 스킵 수를 구하는 문제.
스킵을 하지 않으면 다음 도로는 대기 후 정시에 출발 가능하고 스킵을 하면 바로 출발할 수 있다.
Solution
처음에 짠 최소 스킵 횟수를 반환하는 단순한 4차원 DP로는 시간 초과... (idx, 스킵한 시간, 남은 시간, 스킵한 횟수),
살짝 비틀어서 생각해보면
dp[i][j]: i 인덱스까지 j번 스킵할 때 가능한 최소 거리라고 정의하고 문제를 풀면 쉽게 풀린다.소수점 계산이 까다롭기 때문에 소수점을 무시하기 위해 시간이 아닌 이동 거리를 사용하면 쉽다.
일단 대략적인 모양은 이런 느낌이 되는데, ceil 함수에서 정시까지 기다리는 것을 처리하도록 하였다. 자세한 건 아래 코드 참고.
이제 for 문을 돌면서 0부터 n까지에 대해 i 번 스킵할 때 주어진 시간 안에 도착할 수 있는지 체크해주면 된다. 불가능하면 -1 리턴.
Source Code
All reactions