“My code passed 𝟏𝟎𝟎+ test cases… so I thought I was done.” 😌 Then test case 118 happened. 💀 I was solving the 𝐋𝐨𝐧𝐠𝐞𝐬𝐭 𝐈𝐧𝐜𝐫𝐞𝐚𝐬𝐢𝐧𝐠 𝐒𝐮𝐛𝐬𝐞𝐪𝐮𝐞𝐧𝐜𝐞 (LIS) problem using Dynamic Programming (𝐑𝐞𝐜𝐮𝐫𝐬𝐢𝐨𝐧 + 𝐌𝐞𝐦𝐨𝐢𝐳𝐚𝐭𝐢𝐨𝐧). Everything looked perfect. Clean code. Correct logic. And most importantly — it was passing. Until it didn’t. Large test cases started crashing with runtime errors. That’s when it hit me… 👉 The problem wasn’t my code. 👉 The problem was my thinking. I was using an O(n²) approach for constraints up to 10⁵. No matter how “correct” it is… it’s not scalable. So I switched to the O(n log n) solution using 𝐁𝐢𝐧𝐚𝐫𝐲 𝐒𝐞𝐚𝐫𝐜𝐡. Same problem. Same goal. Completely different performance. 💡 That moment changed how I look at problems: Correct ≠ Efficient Passing ≠ Scalable 𝘿𝙤 𝙮𝙤𝙪 𝙥𝙧𝙞𝙤𝙧𝙞𝙩𝙞𝙯𝙚 𝙘𝙤𝙧𝙧𝙚𝙘𝙩𝙣𝙚𝙨𝙨 𝙛𝙞𝙧𝙨𝙩 𝙤𝙧 𝙨𝙘𝙖𝙡𝙖𝙗𝙞𝙡𝙞𝙩𝙮 ? #DataStructures #Algorithms #DynamicProgramming #CodingJourney #SoftwareEngineering #ProblemSolving #TechLearning #LearnInPublic #Developers #Coding
Longest Increasing Subsequence problem solution with Binary Search
More Relevant Posts
-
Everyone is chasing AI and automation in 2026… but the smartest developers are still mastering what actually makes systems fast. C++ isn’t outdated. It’s the silent engine behind everything we rely on. Performance is not a feature. It’s a foundation. #cpp #programming #automation #softwareengineering #performance #developers #coding #technology #backend #systemsprogramming
To view or add a comment, sign in
-
Day 77 on LeetCode Find Smallest Letter Greater Than Target 🔤🔍✅ Continuing the streak with a clean Binary Search application — keeping things simple and consistent during mids 💯 🔹 Approach Used in My Solution The goal was to find the smallest character strictly greater than the target in a sorted array, with wrap-around behavior. Key idea: • Apply binary search on the sorted array • Whenever letters[mid] > target, store it as a potential answer • Move left to find an even smaller valid character • If no such character exists, return letters[0] (wrap-around case) This ensures we always get the next greatest letter efficiently. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Practiced binary search for “next greater element” problems • Learned how to handle wrap-around edge cases • Reinforced writing clean and optimized search logic 🔥 Small wins every day consistency is the real progress. #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Your code is not slow because of the language. It’s slow because of decisions. Most common mistakes: • unnecessary loops • repeated API calls • poor database queries Switching tech won’t fix this. Thinking better will. Performance is not magic. It’s design. Have you faced this? #softwaredevelopment #programming #developers #coding #techtips
To view or add a comment, sign in
-
-
“Hard” doesn’t always mean complex logic. Today I solved the Text Justification problem on LeetCode. And it taught me something unexpected. At first glance, it looks like one of those problems where you need some crazy algorithm. But that wasn’t the real challenge. The logic? Pretty straightforward. The real difficulty was something else entirely: → Structuring the output → Handling edge cases → Distributing spaces correctly → Staying patient when everything almost works It wasn’t about intelligence. It was about discipline. Line by line. Case by case. That’s when it hit me: Some “hard” problems aren’t hard because of logic… They’re hard because they test your patience and precision. And honestly, that’s a different kind of skill. If you’re stuck on a problem like this, don’t just think harder. Think calmer. Break it down. Control the structure. And keep going. Have you faced a problem that wasn’t logically hard, but mentally exhausting? Drop it below 👇 #leetcode #dsa #programming #coding #softwareengineering #problemsolving #algorithms #codingjourney #growthmindset #patience #consistency #developers #csstudents
To view or add a comment, sign in
-
-
🚀 Day 4 of 100 Days LeetCode Challenge. Problem: Special Positions in a Binary Matrix Today’s problem focused on matrix traversal + counting logic—simple concept, but requires careful observation. 💡 Key Insight: A position (i, j) is special if: mat[i][j] == 1 All other elements in the same row and column are 0 🔍 Efficient Approach: Count number of 1’s in each row Count number of 1’s in each column A position is special only if: Row count = 1 Column count = 1 👉 This avoids unnecessary repeated checks and improves efficiency. 🔥 What I Learned Today: Preprocessing (row & column counts) simplifies problems Avoid brute force → think in terms of frequency/counting Clean logic > complex code 📈 Challenge Progress: Day 4/100 ✅ Staying consistent! LeetCode, Matrix Problem, Arrays, Counting Technique, DSA Practice, Coding Challenge, Problem Solving, Algorithm Thinking, Optimization #100DaysOfCode #LeetCode #DSA #CodingChallenge #Matrix #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
Day 68 on LeetCode Guess Number Higher or Lower 🎯✅ Today’s problem reinforced the power of Binary Search on an answer space. 🔹 Approach Used in My Solution The goal was to identify a hidden number using the provided guess() API. Key idea in the solution: • Apply binary search between 1 and n • Pick mid and call guess(mid) • Based on the response: – 0 → correct number found – -1 → guessed number is too high → move left – 1 → guessed number is too low → move right • Continue narrowing the search space until the number is found This is a perfect example of searching efficiently using feedback. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Strengthened understanding of binary search with external APIs • Learned how to adjust search space based on feedback • Reinforced the concept of searching on answer space 🔥 Another solid step in mastering binary search patterns! #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #DivideAndConquer #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟔 𝐨𝐟 𝐁𝐮𝐢𝐥𝐝 𝐒𝐜𝐚𝐥𝐚𝐛𝐥𝐞 𝐚𝐧𝐝 𝐄𝐟𝐟𝐢𝐜𝐢𝐞𝐧𝐭 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧𝐬 𝐭𝐨 𝐑𝐞𝐚𝐥-𝐖𝐨𝐫𝐥𝐝 𝐂𝐨𝐝𝐢𝐧𝐠 𝐏𝐫𝐨𝐛𝐥𝐞𝐦𝐬 : 𝐃𝐲𝐧𝐚𝐦𝐢𝐜 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐦𝐢𝐧𝐠: 𝐈𝐧𝐭𝐫𝐨𝐝𝐮𝐜𝐭𝐢𝐨𝐧 𝐚𝐧𝐝 𝐎𝐩𝐭𝐢𝐦𝐢𝐳𝐚𝐭𝐢𝐨𝐧 𝐓𝐞𝐜𝐡𝐧𝐢𝐪𝐮𝐞𝐬 Dynamic Programming (DP) is a powerful technique for tackling complex coding problems by breaking them down into smaller, overlapping subproblems. The key? Solving each subproblem only once and storing the results. This memoization or tabulation significantly boosts efficiency, transforming exponential time complexities into polynomial ones. Essential for building scalable solutions. Beyond the basics, consider bitmasking in DP. This lets you represent subsets of elements as binary numbers, enabling you to efficiently track states in problems involving combinations. What’s your favorite dynamic programming optimization technique, and how has it helped you build more efficient solutions? #DynamicProgramming #Algorithms #Coding #SoftwareEngineering #Optimization #DataStructures
To view or add a comment, sign in
-
-
Day 69 on LeetCode Search in Rotated Array (Brute Force Insight) 🔍✅ Today’s problem initially felt tricky, but turned out to be one of the simplest when approached directly. 🔹 Approach Used in My Solution Instead of overcomplicating with rotation logic, I used a straightforward linear search. Key idea: • Traverse the array from start to end • Compare each element with the target • Return the index once found, otherwise -1 Sometimes, the simplest approach is the most reliable. 🔹 Initial Thought Process (Overthinking Phase 😅) • Considered rotating the array and then searching • Thought about adjusting indices using formulas like: (index - rotation + n) % n • But realized that all of this is unnecessary for basic search ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 💡 Key Takeaways: • Not every problem needs an optimized approach — clarity > complexity • Avoid overengineering when a simple solution works perfectly • Always validate if a direct approach solves the problem efficiently enough 🔥 Great reminder: Sometimes the “easy way” is the smart way. #LeetCode #DSA #Algorithms #DataStructures #Arrays #LinearSearch #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 72 on LeetCode Search a 2D Matrix 🔍📊✅ Today’s problem was a great application of Binary Search in 2D, breaking it down into two efficient steps. 🔹 Approach Used in My Solution The goal was to determine whether a target exists in a sorted 2D matrix. Key idea in the solution: • First, apply binary search on rows to find the potential row where the target could exist – Check if target lies between matrix[mid][0] and matrix[mid][cols-1] • Once the correct row is found, apply binary search within that row • Return true if found, otherwise false This avoids scanning the entire matrix and ensures efficiency. 🔹 Why This Works Because: • Each row is sorted • The first element of each row is greater than the last of the previous row So we can treat it like a two-level binary search problem. ⚡ Complexity: • Time Complexity: O(log m + log n) • Space Complexity: O(1) 💡 Key Takeaways: • Learned how to extend binary search to 2D structures • Practiced breaking problems into smaller searchable spaces • Reinforced thinking in terms of hierarchical searching 🔥 Another solid step in mastering binary search patterns! #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #Matrix #2DArray #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 73 on LeetCode Find First and Last Position of Element in Sorted Array 🎯🔍✅ Today’s problem focused on a classic and very important Binary Search variation. 🔹 Approach Used in My Solution The goal was to find the first and last occurrence of a target in a sorted array. Key idea in the solution: • Use two separate binary searches 🔸 Find First Occurrence: • When nums[mid] >= target, move left • If nums[mid] == target, store index and continue searching left 🔸 Find Last Occurrence: • When nums[mid] <= target, move right • If nums[mid] == target, store index and continue searching right • Combine both results to get final answer This ensures we don’t just find a match, but the complete range of the target. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Learned how to modify binary search to find boundaries instead of single elements • Strengthened understanding of first/last occurrence patterns • Realized how small logic changes turn binary search into powerful variants 🔥 This pattern is extremely common in interview problems! #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
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
Scalability comes with correctness.