LeetCode 3633 & 3635 : Earliest Finish Time for Land and Water Rides I & II | O(N*M) to O(N+M)

Опубликовано: 14 Июнь 2026
на канале: DCode Thought
214
9

LeetCode 3633 & 3635: Earliest Finish Time for Land and Water Rides I & II | O(N*M) to O(N+M) Optimization

LeetCode POTD solution explained step-by-step | Java C++ Python.
Learn the real thinking process from getting a Time Limit Exceeded (TLE) on Part II to building a brilliant Greedy Precomputation algorithm! Why Not To Why...

🔗 Problem Links (Code for all languages):
Part I: https://dcodethought.vercel.app/probl...
Part II: https://dcodethought.vercel.app/probl...



Time :
0:00 - Understanding the Problem
5:45 - Brute Force for Part 1
10:30 - Optimal Solution for Part 2



📂 All POTD, Contest Solutions & Many More Explore DCodeThought: https://dcodethought.vercel.app

WalkThrough Video :    • Introducing DCodeThought 🚀 | The Ultimate ...  

🎯 My Goal With This Channel
My aim is not just to show the final solution. My aim is to help you understand why your solution doesn't work and why the correct solution works.

On this channel, we don't jump directly from problem → answer.

Instead we go through the real thinking process across 2 DIFFERENT EVOLUTIONS:
❌ Approach 1: Brute Force All Pairs (O(N * M)) - Perfect for Part I! We use nested loops to check every single (Land, Water) combination. We simulate taking Land first, then Water, and vice versa. But for Part II with 50,000 rides, this gives TLE!
✅ Approach 2: Greedy Precomputation (O(N + M)) - The Ultimate Optimization! For Part II, we realize a crucial greedy property: To finish the second ride as early as possible, the FIRST ride MUST finish as early as possible. We find the absolute minimum finish times for Land and Water separately in O(N) and O(M). Then, we simulate the second ride using these optimal first rides! Lightning fast!

You will learn:
• How to transition from Brute Force nested loops to Linear Time O(N+M) solutions.
• How to identify Independent Subproblems in scheduling logic.
• How to apply Greedy principles to minimize overall completion time.

Because in real coding interviews and contests, thinking matters more than memorizing solutions.
Here we break down LeetCode POTD, contest problems, and important DSA questions with clear explanations so you can build strong problem-solving skills.

If you want to improve your DSA logic, coding intuition, and interview problem solving, this channel is for you.

Welcome to DCodeThought — where we focus on thinking, not just coding.

---

💻 Solutions explained in:
Java | C++ | Python

📌 Topics covered in this video:
LeetCode POTD
Greedy Algorithms
Time & Space Complexity Optimization
Array Traversal & Scheduling Simulation
Math & Logic Building
Competitive Programming Logic

---

🔔 Subscribe for daily problem solving and logical thinking.

---

Tags:
LeetCode 3633, LeetCode 3635, Earliest Finish Time for Land and Water Rides, LeetCode 3633 solution, LeetCode 3635 Java, LeetCode 3635 C++, LeetCode 3635 Python, LeetCode POTD, Greedy Algorithm, Array Optimization, Scheduling problems, Blind 75 LeetCode, NeetCode 150, FAANG interview questions, Google interview questions, Amazon coding interview, DCodeThought, DSA, Data Structures and Algorithms, DSA in Java, DSA in C++, DSA in Python, competitive programming, competitive programming tutorial, coding interview questions, software engineering interview, WA to AC, learn coding, DSA preparation, LeetCode Hindi solutions, coding intuition.

Hashtags:
#LeetCode3633 #LeetCode3635 #GreedyAlgorithm #ArrayOptimization #LeetCodePOTD #DSA #DataStructures #Algorithms #CodingInterview #FAANGPrep #Java #CPP #Python #CompetitiveProgramming #DCodeThought #LearnCoding #CodingLogic #SoftwareEngineering #TechInterview #CodeNewbie #100DaysOfCode #LeetCodeDailyChallenge