Day 18/100 💻 Today’s challenge was all about optimizing finger movement on a keyboard using dynamic programming. The goal: minimize total distance while typing a word with two fingers. 🧠 Key takeaway: Instead of thinking greedily, we track both finger positions at every step and choose the move that gives the minimum cumulative cost. This problem really highlights how DP can turn an exponential decision space into something efficient. ⚡ Learned: State design is everything in DP Reusing previous computations avoids redundant work Sometimes “free starting positions” can simplify complexity 🚀 Progress: 18 days down, 82 to go! #100DaysOfCode #DataStructures #DynamicProgramming #ProblemSolving #CodingJourney
Optimizing Finger Movement with Dynamic Programming
More Relevant Posts
-
Day 245 of 365 Days of Code 🚀 Dived deep into Dynamic Programming today with a really interesting two-pointer/finger optimization problem. Worked on minimizing typing distance by modeling states as positions of two fingers on a grid. The key insight was defining DP states smartly — instead of tracking both fingers explicitly, optimizing transitions by fixing one and iterating over the other reduced complexity significantly. Also reinforced how powerful state compression can be when dealing with multi-variable DP problems. Key takeaway: In DP, the real challenge isn’t transitions — it’s defining the right state. #365DaysOfCode #DynamicProgramming #DSA #CodingJourney
To view or add a comment, sign in
-
-
Implemented a menu-driven Queue using C 💻 Built a simple program demonstrating core queue operations: • Enqueue (Insertion) • Dequeue (Deletion) • Display Worked with front and rear pointers to manage the queue and handled edge cases like overflow and underflow. Attached a short video demo showing the program in action 🎥 This helped reinforce my understanding of data structures and modular coding in C. Next step: implementing a circular queue for better efficiency. #CProgramming #DataStructures #Queue #CodingPractice #LearningByDoing
To view or add a comment, sign in
-
Day 3 of My Dynamic Programming Journey Today I worked on Minimum Path Sum, and it really helped me strengthen my understanding of grid-based DP and optimization. Key Idea: At each cell, the minimum path sum depends on: From top From left So, min path = min(top, left) + current cell value Big Learning: I implemented an optimized solution using 1D DP (space optimization) instead of a full 2D matrix. dp[j] → represents path sum from top dp[j-1] → represents path sum from left Important Insight: Handling edge cases like the first row and first column is crucial. A small mistake in updating values (reset vs accumulate) can break the entire logic. Key Takeaway: “Always compare path sums, not grid values — and build solutions step by step from intuition to optimization.” Next Goal: Moving towards decision-based DP problems like House Robber to explore new patterns. #DynamicProgramming #DSA #CodingJourney #ProblemSolving #LeetCode #LearningInPublic #Day3
To view or add a comment, sign in
-
-
🚀 Day 68 of #100DaysOfLeetCode ✅ Solved: Minimum Path Sum (LeetCode #64) Today’s problem was a classic Dynamic Programming (Grid DP) challenge. The goal was to find the minimum sum path from the top-left to the bottom-right of a grid, moving only right or down. 💡 Key Insight: At each cell, the minimum path depends on the minimum of: the value from the top the value from the left So we build the solution step-by-step using DP. 🧠 What I Learned: How to break down grid problems into subproblems Importance of defining DP state clearly Space optimization by modifying the input grid ⚡ Performance: Runtime: 4 ms Beat ~63% of submissions 📈 Consistency is key — small improvements every day add up! #LeetCode #DataStructures #Algorithms #DynamicProgramming #CodingJourney #PlacementPreparation
To view or add a comment, sign in
-
-
🚀 Day 11/100 — 💻 Problem: 0/1 Knapsack Given the weights & values of items, maximize value without exceeding capacity Concept: Dynamic Programming At each step, we decide: — Include the item — OR skip the item Take the maximum of both choices! def knapsack(weights, values, W, n): dp = [[0 for _ in range(W + 1)] for _ in range(n + 1)] for i in range(1, n + 1): for w in range(1, W + 1): if weights[i-1] <= w: dp[i][w] = max( values[i-1] + dp[i-1][w - weights[i-1]], dp[i-1][w] ) else: dp[i][w] = dp[i-1][w] return dp[n][W] What I learned: Every problem is a choice →include or exclude DP helps avoid recomputing subproblems. Time Complexity: O(n × W) This is the foundation for many advanced DP problems. #100DaysOfCode #DSA #DynamicProgramming #Knapsack #CodingInterview #ProblemSolving #PlacementPrep #LearnInPublic
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 74/100 ✅ Shifted to a new category in Dynamic Programming — DP on Subsequences. This feels very different from grid problems. Worked on patterns like: - Pick / Not Pick - Subset Sum type thinking - Basic recursion → DP conversion At first, it was confusing: Instead of moving in a grid, now it’s about making decisions at each index. 👉 Include the element 👉 Or skip it And based on that, build the answer. Big realization today: DP is not tied to a problem type (arrays, grids, etc.) It’s about decision making at each step + storing results. Also noticed: If the recursion is clear (pick / not pick), memoization becomes much easier to implement. Still slow in identifying states here, but starting to understand the pattern. Back again tomorrow 🚀
To view or add a comment, sign in
-
🚀 Day 212 of #300DaysOfCoding Today I solved a challenging DP problem: 👉 Minimum Distance to Type a Word Using Two Fingers This problem really tested my understanding of Dynamic Programming, state optimization, and decision making. 🧠 Key Learning At every step, we have two choices: Use finger 1 Use finger 2 The goal is to minimize total movement distance I implemented a DP solution where: State = positions of both fingers Transition = try both fingers and take minimum ⚙️ Approach Represent each character as coordinates on a grid Use Manhattan Distance for movement Apply Bottom-Up DP (27 × 27 states) Optimize transitions carefully to avoid recomputation 💡 What I Learned DP problems are not just about memorization — they are about thinking in states and transitions Small mistakes in optimization can completely break the solution 😅 Debugging teaches more than solving 🧪 Example Input: "CAKE" Output: 3 🔥 Takeaway Consistency is the real game changer. Every day, I’m getting better at problem-solving and thinking logically. #300DaysOfCoding #DataStructures #Algorithms #DynamicProgramming #CodingJourney #LeetCode #Cplusplus #ProblemSolving
To view or add a comment, sign in
-
-
Climbing Stairs Using Dynamic Programming Day 13 👈 💡 Key Insight: This problem follows a Fibonacci pattern: Ways(n) = Ways(n-1) + Ways(n-2) 🔁 Optimization: Used memoization (top-down DP) to store previously computed results Avoided recalculating the same subproblems ⚡ Time Complexity improved: From O(2ⁿ) → O(n) #DSA #DynamicProgramming #Memoization #Algorithms #CodingJourney #LeetCode #ProblemSolving #InterviewPreparation #SoftwareEngineer #LearningInPublic
To view or add a comment, sign in
-
-
I don't believe in skill.md files. When you use them, you are trying to make waves behave like particles. I use phil.md files, where I put ~300 lines of text on programming philosophy and a couple of architectural ideas. I care about constraining the distribution of results, not the specific path the model takes.
To view or add a comment, sign in
-
Started Dynamic Programming today ....... Covered 3 core approaches: 🔹 Memoization — cache results, avoid recomputation 🔹 Tabulation — build the solution bottom-up 🔹 Space Optimized Tabulation — same results, less memory Applied all three to Fibonacci & LeetCode's Climbing Stairs. The progression from O(2ⁿ) brute force → O(n) DP → O(1) space feels incredibly satisfying. #DynamicProgramming #LeetCode #DSA #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
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