🚀 Day 214 of #300DaysOfCoding Today I solved a Hard-level problem on LeetCode: 👉 Minimum Total Distance Traveled This problem really tested my understanding of Dynamic Programming + Greedy Thinking. 💡 Key Learnings: Sorting plays a crucial role in optimizing 1D distance problems Converting real-world constraints into DP states makes complex problems manageable Handling capacity constraints (factories limit) using iterative assignment 🧠 Approach: Sorted robots and factories based on position Used DP + Memoization to assign robots to factories efficiently Tried multiple assignments per factory within capacity limits ⚡ Why this problem is interesting? It combines: Greedy intuition (nearest assignment) Dynamic Programming (optimal substructure) Real-world modeling (capacity constraints) 📊 Complexity: Time: O(n × m × limit) Space: O(n × m) 🔥 Problems like this improve problem-solving depth and prepare you for top product-based companies. #LeetCode #DSA #DynamicProgramming #CodingJourney #ProblemSolving #SoftwareEngineering #MCA #GATEPreparation
Love Kumar’s Post
More Relevant Posts
-
🚀 Day 22 of 100 Days LeetCode Challenge Problem: Determine Whether Matrix Can Be Obtained By Rotation Day 22 is a classic matrix rotation + simulation problem 🔥 💡 Key Insight: We can rotate the matrix in 90° steps (up to 4 times): 90° 180° 270° 360° (back to original) 👉 If at any step mat == target → ✅ True 🔍 Core Approach: 1️⃣ Rotate Matrix (90° Clockwise) Transpose the matrix Reverse each row 👉 This gives one 90° rotation 2️⃣ Repeat Rotation 4 Times After each rotation: Compare with target 👉 If match found → return true 👉 Else after 4 rotations → false 💡 Optimization: Early exit when match is found Avoid unnecessary rotations 🔥 What I Learned Today: Matrix rotation is a standard pattern Simulation problems require step-by-step accuracy Reusing logic reduces complexity 📈 Challenge Progress: Day 22/100 ✅ Staying consistent & sharp! LeetCode, Matrix, Rotation, Simulation, Arrays, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Matrix #Rotation #Simulation #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
🔥 Day 554 of #750DaysofCode 🔥 🚀 Problem Solved: Walking Robot Simulation Today’s problem tested my simulation + hashing skills in a really interesting way! 🤖 What I implemented: I simulated the robot’s movement step-by-step on an infinite grid while handling obstacles efficiently. 💡 Instead of using complex structures, I used: 👉 HashSet to store blocked positions 👉 Direction array to manage movement (N, E, S, W) 🧠 Core Idea: Maintain current direction using an index Rotate: Right → (dir + 1) % 4 Left → (dir + 3) % 4 Move one step at a time (very important 🚨) Before every step: Check if next position is blocked If yes → stop moving for that command ⚡ Key Insight: 👉 You cannot jump directly k steps 👉 You MUST move step-by-step to correctly detect obstacles 💻 My Approach: ✔️ Stored obstacles as "x,y" in HashSet ✔️ Used direction vector: North → (0,1) East → (1,0) South → (0,-1) West → (-1,0) ✔️ Tracked max distance using: 👉 x² + y² 📈 Complexity: Time: O(N + total steps) Space: O(M) for obstacles 🎯 What I learned: Simulation problems require careful step execution Hashing makes obstacle lookup super fast Small implementation details can make or break the solution 💬 Honestly, this problem looks easy at first, but handling directions + obstacles correctly makes it a great practice problem! #Day554 #750DaysOfCode #LeetCode #Java #DSA #CodingJourney #ProblemSolving #Developers #Tech
To view or add a comment, sign in
-
-
🚀 Day 36 of 100 Days LeetCode Challenge Problem: Robot Return to Origin Day 36 is a simple but important simulation + counting problem 🔥 💡 Key Insight: To return to origin (0,0): Total moves Right = Left Total moves Up = Down 👉 If both conditions satisfy → ✅ robot returns to origin 🔍 Core Approach: 1️⃣ Initialize Counters x = 0, y = 0 2️⃣ Process Each Move 'R' → x++ 'L' → x-- 'U' → y++ 'D' → y-- 3️⃣ Final Check If (x == 0 && y == 0) → true Else → false 💡 Alternative Approach: Count occurrences: count('R') == count('L') count('U') == count('D') 🔥 What I Learned Today: Simple problems test basic logic clarity Simulation problems are about correct tracking Don’t overcomplicate—keep it clean 📈 Challenge Progress: Day 36/100 ✅ Consistency still going strong! LeetCode, Simulation, Strings, Counting, Coordinates, Arrays, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Simulation #Strings #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
LeetCode POTD | Day 29 2463. Minimum Total Distance Traveled Today’s problem was a bit more challenging compared to the last few days. I used a dynamic programming approach with recursion and memoization. First, I sorted both robots and factories, then tried assigning robots to factories in an optimal way while minimizing the total distance. The DP helped avoid recalculating overlapping subproblems. What I learned today: • When multiple decisions are involved, try thinking in terms of DP with states and transitions • Sorting beforehand can simplify the problem and make greedy or DP approaches easier to apply • Memoization is a lifesaver when recursion starts repeating work #LeetCode #DSA #POTD #CodingJourney #ProblemSolving #DynamicProgramming #DailyCodingChallenge
To view or add a comment, sign in
-
-
🚀 Day 27 of 100 Days LeetCode Challenge Problem: Matrix Similarity After Cyclic Shifts Day 27 brings a neat simulation + modular arithmetic problem 🔥 💡 Key Insight: Shifting happens k times, but instead of simulating k steps: 👉 We can reduce it using modulo Effective shifts = k % n (where n = number of columns) 🔍 Core Approach: 1️⃣ Understand Row Behavior Even rows → shift left Odd rows → shift right 2️⃣ Apply Optimized Shift For each row: Calculate effective shift using modulo Perform one optimized shift instead of k times 3️⃣ Compare with Original Matrix If all rows match → ✅ true Else → ❌ false 💡 Why Modulo Works: After n shifts, row returns to original state → avoids unnecessary computation 🚀 🔥 What I Learned Today: Repeated operations → think modulo optimization Simulation problems can often be simplified Understanding patterns saves time 📈 Challenge Progress: Day 27/100 ✅ Closing in on 30! LeetCode, Matrix, Simulation, Cyclic Shift, Modular Arithmetic, Arrays, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Matrix #Simulation #ModularArithmetic #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
🧠 Day 207 — Minimum Total Distance Traveled 🤖🏭📍 Today solved a powerful DP + Greedy intuition problem involving robots and factories. 📌 Problem Goal Given positions of robots and factories (with capacity): ✔️ Assign each robot to a factory ✔️ Minimize the total distance traveled 🔹 Core Idea First, sort both: ✔️ Robots by position ✔️ Factories by position Then expand factories based on their capacity → convert into multiple slots 👉 Now the problem becomes: Assign robots to factory slots in an optimal way 🔹 DP Thinking At each step: 1️⃣ Assign current robot to current factory slot 2️⃣ Skip current factory slot Take the minimum cost of both choices 🔹 Key Observation ✔️ This is a classic 2-pointer + DP decision problem ✔️ Order matters → sorting is crucial ✔️ Greedy alone is not enough, DP ensures optimal assignment 🧠 Key Learning ✔️ Converting capacity problems into linear structures simplifies DP ✔️ “Take / Not Take” is a powerful pattern ✔️ Always think about sorting when distance minimization is involved 💡 Big Realization Many assignment problems are hidden DP problems. If you see: 👉 “Minimize total cost” 👉 “Pair elements optimally” Start thinking in terms of DP on indices. 🚀 Momentum Status: DP patterns getting deeper and more intuitive. On to Day 208. #DSA #DynamicProgramming #Greedy #LeetCode #Java #CodingJourney #ConsistencyWins
To view or add a comment, sign in
-
-
🚀 Day 555 of #750DaysOfCode 🚀 🧠 Today’s Problem: Walking Robot Simulation II (LeetCode - Medium) This problem was all about simulation + optimization. At first glance, it looks like a simple movement problem, but the tricky part is handling direction changes at boundaries efficiently. 💡 Key Insights: The robot moves along the perimeter of the grid. Instead of simulating every step (which could be up to 10⁵), we optimize using: 👉 perimeter = 2*(width - 1) + 2*(height - 1) We reduce steps using modulo: 👉 num %= perimeter Then simulate movement in chunks based on current direction. ⚙️ What I implemented: Maintained (x, y) position and current direction Handled boundary collisions → turn 90° counterclockwise Efficient movement without iterating step-by-step 🔥 Learning Takeaways: Simulation problems often hide optimization opportunities Always look for patterns (like cycles/perimeters) Clean direction handling makes logic much easier 💻 Tech Used: Java, OOP, Simulation Logic Consistency > Motivation. Showing up every day 💪 #LeetCode #Java #ProblemSolving #DataStructures #Algorithms #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 95 Today’s problem: Robot Return to Origin (Easy) A simple yet insightful problem focused on movement tracking and coordinate logic. The idea is straightforward — simulate the robot’s moves and check whether it ends up back at the origin (0,0). 💡 Key Takeaways: Maintain two variables (x, y) to track position Each move updates coordinates accordingly Final check: if (x == 0 && y == 0), the robot returns to origin ✅ Clean logic > overthinking ⚡ Result: Accepted ✅ ⏱ Runtime: 0 ms (100% 💯) 📊 Memory: Room for improvement Even the “easy” problems reinforce fundamentals — and strong fundamentals win interviews. Consistency is the real game. On to Day 96 💪 #LeetCode #Programming #DSA #CodingJourney #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
Spent an hour on Hurdle 4 in Reeborg’s World—and it was worth it. Loops are easy to write, but conditions are what actually make the logic work. One wrong condition, and the robot either crashes or keeps looping forever. This exercise made one thing clear: Coding isn’t about writing more instructions—it’s about writing the right conditions. Small progress, but real learning. Try to solve it.
To view or add a comment, sign in
-
-
I'm happy to share this, hope it helps someone. During my time in the automotive industry, I built a real-time quality control tool using computer vision, designed to detect wire harness components directly on the production line. The app worked great, but completely tied to proprietary data, so it stayed private. I've now cleaned it up, stripped all company specific elements, swapped the custom model for a publicly available YOLOv8 one, and restructured the codebase into a proper modular template that anyone can use. What it does: - Runs real-time object detection from a webcam or image file. - Displays detected objects with class labels and confidence scores. - Exports results as a text report or PDF label. Seneca once wrote in his Letters to Lucilius: “If wisdom were given me under the express condition that it must be kept hidden and not uttered, I should refuse it.” I’m no Seneca, but I think this may be useful for someone; feel free to use it, fork it, or build on it. For more details, check the README on GitHub: https://lnkd.in/dMdKb4Xe #Python #ComputerVision #YOLO #OpenSource #MachineLearning
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development