- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
LeetCode 3633 - Earliest Finish Time Land and Water Rides | June 1 POTD | Brute Force | Java | Easy
🔥 LeetCode 3633 - Earliest Finish Time for Land and Water Rides I | June 1 POTD
📌 Problem:
Given land rides and water rides, each with a start time and duration,
a tourist must do exactly ONE from each category in either order.
A ride starts at its open time or later.
Return the earliest possible time to finish BOTH rides.
Example 1:
landStartTime = [2,8], landDuration = [4,1]
waterStartTime = [6], waterDuration = [3]
Output: 9
Best plan: land ride 0 → water ride 0 = finish at 9
Example 2:
landStartTime = [5], landDuration = [3]
waterStartTime = [1], waterDuration = [10]
Output: 14
Best plan: water ride 0 → land ride 0 = finish at 14
💡 Approach: Brute Force — Try All Pairs Both Orders
Since n and m are at most 100, we can try every combination!
For each pair (land ride i, water ride j) try BOTH orders:
Order 1 — Land first then Water:
→ land finish = lST[i] + lD[i]
→ water start = max(land finish, wST[j])
→ total finish = water start + wD[j]
Order 2 — Water first then Land:
→ water finish = wST[j] + wD[j]
→ land start = max(water finish, lST[i])
→ total finish = land start + lD[i]
Track global minimum across all pairs and both orders!
Key formula — "start as early as possible after previous ride":
→ max(previous finish time, ride open time) + ride duration
→ max() handles the waiting time naturally!
⏱ Complexity:
- Time: O(n * m) — try all pairs, both orders
- Space: O(1) — only tracking minimum result
✅ Difficulty: Easy
📅 June 1, 2025 — FIRST POTD of June! 🎉
━━━━━━━━━━━━━━━━━━━━━━━
🔗 Problem Link:
https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-i/
━━━━━━━━━━━━━━━━━━━━━━━
#leetcode #java #bruteforce #simulation #dsa #leetcodedaily
#potd #leetcodeEasy #competitiveprogramming #june1potd
#leetcode3633 #themepark #tryallpairs #junestart #mustwatch
Видео LeetCode 3633 - Earliest Finish Time Land and Water Rides | June 1 POTD | Brute Force | Java | Easy канала Vishant Sandilya
📌 Problem:
Given land rides and water rides, each with a start time and duration,
a tourist must do exactly ONE from each category in either order.
A ride starts at its open time or later.
Return the earliest possible time to finish BOTH rides.
Example 1:
landStartTime = [2,8], landDuration = [4,1]
waterStartTime = [6], waterDuration = [3]
Output: 9
Best plan: land ride 0 → water ride 0 = finish at 9
Example 2:
landStartTime = [5], landDuration = [3]
waterStartTime = [1], waterDuration = [10]
Output: 14
Best plan: water ride 0 → land ride 0 = finish at 14
💡 Approach: Brute Force — Try All Pairs Both Orders
Since n and m are at most 100, we can try every combination!
For each pair (land ride i, water ride j) try BOTH orders:
Order 1 — Land first then Water:
→ land finish = lST[i] + lD[i]
→ water start = max(land finish, wST[j])
→ total finish = water start + wD[j]
Order 2 — Water first then Land:
→ water finish = wST[j] + wD[j]
→ land start = max(water finish, lST[i])
→ total finish = land start + lD[i]
Track global minimum across all pairs and both orders!
Key formula — "start as early as possible after previous ride":
→ max(previous finish time, ride open time) + ride duration
→ max() handles the waiting time naturally!
⏱ Complexity:
- Time: O(n * m) — try all pairs, both orders
- Space: O(1) — only tracking minimum result
✅ Difficulty: Easy
📅 June 1, 2025 — FIRST POTD of June! 🎉
━━━━━━━━━━━━━━━━━━━━━━━
🔗 Problem Link:
https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-i/
━━━━━━━━━━━━━━━━━━━━━━━
#leetcode #java #bruteforce #simulation #dsa #leetcodedaily
#potd #leetcodeEasy #competitiveprogramming #june1potd
#leetcode3633 #themepark #tryallpairs #junestart #mustwatch
Видео LeetCode 3633 - Earliest Finish Time Land and Water Rides | June 1 POTD | Brute Force | Java | Easy канала Vishant Sandilya
Комментарии отсутствуют
Информация о видео
10 ч. 12 мин. назад
00:11:00
Другие видео канала
