📅 Day 50 — 100 Days of Coding Challenge 🧠 Problem Solved: Perfect Squares (LeetCode 279) Today’s problem focused on finding the minimum number of perfect square numbers whose sum equals a given number n. 🔍 Problem Summary We are given an integer n and need to: 1️⃣ Use only perfect squares (1, 4, 9, 16, …) 2️⃣ Select the minimum count of such squares 3️⃣ Return the least number of squares whose sum is n ⚙️ Approach Used (Recursive / Brute Force) 1️⃣ Try all perfect squares ≤ n 2️⃣ Subtract the chosen square from n 3️⃣ Recursively solve the remaining value 4️⃣ Take the minimum count among all possibilities 💡 Key Learnings 1️⃣ This is a classic DP optimization problem 2️⃣ Brute force recursion works but causes overlapping subproblems 3️⃣ Memoization / DP can significantly reduce time complexity Day 50 completed — halfway through the challenge 💪🔥 #100DaysOfCode #LeetCode #DP #Recursion #ProblemSolving #DeveloperJourney
Swayam Kumar’s Post
More Relevant Posts
-
Steal this idea. A Claude Code wrapper that goes line-by-line and module-by-module to explain the code and reasons behind it, plus also allowing you to intervene / comment at any level. Issue with vibe-coding is loss of control, which is inevitable when 100+ lines of code are thrown at you in one go. Coding something well is having a model of the problem in your head, so AI-assisted coding should help you with that.
To view or add a comment, sign in
-
Steal this idea. A Claude Code wrapper that goes line-by-line and module-by-module to explain the code and reasons behind it, plus also allowing you to intervene / comment at any level. Issue with vibe-coding is loss of control, which is inevitable when 100+ lines of code are thrown at you in one go. Coding something well is having a model of the problem in your head, so AI-assisted coding should help you with that.
To view or add a comment, sign in
-
-
I thought I “knew backtracking” after solving LeetCode 46. Then LeetCode 47 humbled me. Same code. Same logic. Still wrong. Because duplicates don’t care about your confidence. Here’s the uncomfortable truth: Most of us don’t struggle with new concepts — we struggle when a problem adds one extra constraint and exposes shallow understanding. Permutations II isn’t hard. What’s hard is realizing: Copy-pasting LC 46 logic doesn’t work “Used array” alone isn’t enough If you don’t control duplicates, your recursion will happily lie to you Sorting + skipping duplicates isn’t a trick. It’s the difference between knowing a pattern and understanding it.
To view or add a comment, sign in
-
-
🔹 Day 116 – LeetCode Practice 📌 Problem: Sort Colors (LeetCode #75) 📊 Difficulty: Medium 🧠 Problem Overview: Given an array containing only 0, 1, and 2, sort the array in-place so that all 0s come first, followed by 1s, then 2s. 🎯 Key Idea: Since the values are limited to three types, we can count occurrences and rebuild the array in sorted order. ✅ Approach Used: Traverse the array and count how many 0s, 1s, and 2s Overwrite the array with the counted number of 0s, then 1s, then 2s 📈 Submission Results: Status: Accepted ✅ Runtime: 0 ms (Beats 100%) 🚀 Memory Usage: 43.47 MB (Beats 72.76%) 💡 What this problem reinforces: Counting-based sorting technique In-place array manipulation Using problem constraints to design optimal solutions
To view or add a comment, sign in
-
-
Day 13 of 30-day Coding Sprint Today's challenge was a perfect lesson in why complexity analysis matters. When the input reaches 10^15, O(n) isn't just slow, it's impossible. 1922. Count Good Numbers - The Logic: Even indices (0, 2, 4 ...) must be even digits (0, 2, 4, 6, 8) → 5 possibilities. - Odd indices (1, 3, 5 ...) must be prime digits (2, 3, 5, 7) → 4 possibilities. Total "Good" numbers = 5^even _indices * 4^odd_indices. The Bottleneck: With n up to 10^15, a simple loop to calculate power will result in a Time Limit Exceeded (TLE) error. We need to jump from O(n) to O(log n). - The Optimal Strategy: Binary Exponentiation + BigInt - Binary Exponentiation: By halving the power at each step, x^n = (x^n/2)^2, we calculate the result in logarithmic time. BigInt & Modulo: Handling numbers this large in JavaScript requires BigInt to prevent precision loss and consistent % mod operations to avoid overflow. Note: In the world of Big Data and 10^15 constraints, math is your best optimization tool. Transitioning from O(n) to O(log n) is the difference between a program that runs for days and one that finishes in milliseconds. #30DaysOfCode #DSASprint #LeetCode #JavaScript #BigInt #Recursion #Math #Complexity
To view or add a comment, sign in
-
-
Hello connections, Here is my solution to a LeetCode problem focused on dynamic programming and string manipulation. Time Complexity: O(N × M) Space Complexity: O(N × M) Learning from the problem: The key idea is to model the problem using dynamic programming, where each state represents the minimum ASCII delete cost needed to make two prefixes of the strings equal. When characters match, no deletion is required; otherwise, we choose the cheaper deletion between the two strings. This approach systematically explores all possibilities and guarantees the optimal result. This problem is a great example of how DP helps balance multiple choices while minimizing cost. #leetcode #problemsolving #cpp #dynamicprogramming #strings #datastructures #happycoding
To view or add a comment, sign in
-
-
🚀 Day 186 of #500DaysOfCode Today’s challenge was LeetCode 712 – Minimum ASCII Delete Sum for Two Strings 🧵 This problem was a great example of applying Dynamic Programming to string matching. The goal: make two strings equal with minimum deletion cost, where each deletion costs its ASCII value. 💡 Key insight: Think beyond classic LCS—here, the cost of deletion matters. A DP approach comparing characters and choosing the minimum ASCII sum at each step makes all the difference. Every problem like this sharpens intuition for string DP patterns 🔁 On to the next one! #LeetCode #DSA #DynamicProgramming #Strings #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🔹 Day 101 – LeetCode Practice 📌 Problem: Permutations (LeetCode #46) 📊 Difficulty: Medium 🧠 Problem Overview: Given an array of distinct integers, the task is to generate all possible permutations of those numbers. Each permutation must contain every element exactly once, and the order of results doesn’t matter. ✅ Key Idea: Build permutations step by step. At each stage, choose a number that hasn’t been used yet. Continue until a full-length arrangement is formed. Store every complete arrangement as a valid permutation. 📈 Submission Results: Status: Accepted ✅ Runtime: 2 ms Performance: Beats 39.30% Memory Usage: 45.73 MB 💡 Reflection: This problem is a great introduction to backtracking and recursion thinking. It trains you to explore all possibilities while carefully undoing choices—a core skill for many advanced DSA problems. 🚀 Strong consistency, Ananth. Keep pushing—these medium-level problems are building real depth now.
To view or add a comment, sign in
-
-
Day 32 / 160 – LeetCode Journey 🚀 Solved Sort Colors today, and this one really highlights how much thinking matters more than code length. At first, it looks like a simple sorting problem. But the constraints force you to think differently no library sort, constant space, single pass. That’s where the real challenge begins. The key insight is realizing that you don’t need to fully sort the array. You just need to partition it correctly. By maintaining three regions one for 0s, one for 1s, and one for 2s the array gradually organizes itself as you scan it only once. What I liked about this problem is how clean the final logic looks compared to how non-obvious it is at the start. It’s a great reminder that good algorithms often feel simple after you understand them. This problem also connects nicely with earlier two-pointer and sliding window problems different goal, same disciplined pointer movement. Solid medium. Good learning. On to the next one. #LeetCode #DSA #TwoPointers #Arrays #ProblemSolving #LearningInPublic #Consistency
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