📅 Day 54 — 100 Days of Coding Challenge 🧠 Problem Solved: Permutations II (LeetCode 47) Today’s problem was about generating all unique permutations from an array that may contain duplicate elements. 🔍 Problem Highlights 1️⃣ Input array can have repeated numbers 2️⃣ Need all possible permutations 3️⃣ Duplicate permutations are not allowed ⚙️ Approach Used — Backtracking 1️⃣ Fix one position at a time 2️⃣ Use a visited map at each recursion level 3️⃣ Skip elements already used at the same level 4️⃣ Swap → recurse → backtrack This ensures only unique permutations are generated efficiently. 💡 Key Takeaways 1️⃣ Duplicate handling depends on recursion level 2️⃣ Local visited map avoids repeated states 3️⃣ Backtracking with pruning improves performance Day 54 completed — consistency over everything 🚀 #100DaysOfCode #LeetCode #Backtracking #Recursion #DSA #ProblemSolving #CodingJourney
100 Days of Coding Challenge: Permutations II Solution
More Relevant Posts
-
📅 Day 55 — 100 Days of Coding Challenge 🧠 Problem Solved: Combination Sum (LeetCode 39) Today’s problem focused on finding all unique combinations where numbers can be used unlimited times to reach a target sum. 🔍 Problem Highlights 1️⃣ Candidates are distinct integers 2️⃣ Each number can be reused multiple times 3️⃣ Order of combinations doesn’t matter 4️⃣ Only unique combinations are allowed ⚙️ Approach Used — Backtracking 1️⃣ Start from a given index to avoid duplicates 2️⃣ Pick a number → reduce target 3️⃣ Recurse with the same index (reuse allowed) 4️⃣ Backtrack after each recursive call 5️⃣ Stop when target becomes 0 or negative 💡 Key Takeaways 1️⃣ Index-based recursion prevents duplicate combinations 2️⃣ Backtracking is ideal for combination problems 3️⃣ Unlimited reuse requires careful index handling Day 55 completed 🚀 Onward to the next problem! #100DaysOfCode #LeetCode #Backtracking #Recursion #DSA #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Good evening, folks 👋 Day 2–3 / 100 — #100DaysOfCode Maintained a 2-day consistency streak by focusing on core array problems on LeetCode and reinforcing fundamental problem-solving patterns. ✅ Problems Solved 121. Best Time to Buy and Sell Stock → Optimized using a single-pass greedy approach by tracking minimum price and maximum profit. 283. Move Zeroes → In-place solution using the two-pointer technique with O(1) extra space. 26. Remove Duplicates from Sorted Array → Efficient slow–fast pointer strategy leveraging the sorted property. 1. Two Sum → Solved using a hash map to achieve O(n) time complexity. 🔍 Key Takeaways Most array problems reduce to pattern recognition (two pointers, hashing, greedy). Writing optimal solutions is easier once constraints and invariants are clear. Revisiting “easy” problems with an optimization mindset is still valuable. #100DaysOfCode #LeetCode #DSA #ProblemSolving #SoftwareEngineering #Consistency
To view or add a comment, sign in
-
Ever thought “clean” code could secretly slow you down? 🛑 On Day 26, I tackled LeetCode 27 — Remove Element — and locked in another critical mindset: **overwrite, don’t delete**. Daily Engineering Practice — Day 26: LC 27 — Remove Element Pattern: Two Pointers — Same Direction (Read/Write) Key Insight: Deleting elements while iterating triggers repeated shifts — O(n²) silently. Instead, use a slow “write” pointer and a fast “scan” pointer to overwrite unwanted values in-place. Everything beyond the slow pointer is logically ignored, ensuring linear-time operations. Invariant: nums[0..slow-1] contains valid elements slow = number of valid elements Outcome: • Solved LC 27 on LeetCode — O(n) time, O(1) space • Re-enforced the slow/fast pointer pattern • Internalized overwrite as the go-to strategy for in-place array manipulation Question: How do you handle in-place array clean-up efficiently in your projects? Share your tips below! 👇 Code / Practice: GitHub link in the first comment! 👇 #LeetCode #DSA #TwoPointers #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
-
Day 30/100 days of coding 🚀 Problem: Check If Two String Arrays Are Equivalent 🔍 Main Idea 💡 -Concatenate all strings from both arrays -Compare the final formed strings Approach 🛠️ -Traverse word1 and build a single string -Traverse word2 and build another string -If both strings are equal → return true ✅ -Otherwise → return false ❌ What I learned 📘 -Simple logic can solve problems efficiently -Not every problem needs heavy optimization On to Day 31 🚀🚀 #DSA #LeetCode #Strings #100DaysOfCode #Consistency
To view or add a comment, sign in
-
-
Stop using `.pop()` or `delete` inside loops. It’s a silent O(n²) performance trap. 🛑 On Day 25, I solved LeetCode 26 and locked in a critical mindset shift: Overwrite, don’t delete. Day 25 — LeetCode 26: Remove Duplicates from Sorted Array Pattern: Two Pointers (Same Direction / Read–Write) Key Insight: Physically deleting elements forces costly shifts. Instead, overwrite “junk” values by copying unique elements forward into a prefix. Everything after the unique count is logically irrelevant. Invariant: nums[0..slow] always contains unique, sorted elements. Outcome: • Solved & submitted — O(n) time, O(1) space • Replaced expensive deletions with pointer-based overwrites • Fixed a common beginner mistake in in-place array problems Question: How do you handle array clean-up when performance matters? Code / Practice: GitHub → https://lnkd.in/du4FcjyK #LeetCode #DSA #TwoPointers #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
-
Day 22 / 160 – LeetCode Journey 🚀 Text Justification was exhausting, in a good way. This is one of those problems where nothing is conceptually difficult, yet everything has to be exactly right. Every rule matters. Every edge case matters. Miss one condition, and the output is wrong. At first, the problem statement itself felt overwhelming. There are multiple rules layered on top of each other: greedy packing, even space distribution, left-heavy spacing, last-line exceptions, single-word exceptions. It’s not something you can brute-force or “hack” your way through. The only way forward was to slow down and treat it like a real system: pack words greedily calculate space distribution carefully handle special cases explicitly instead of hoping they work themselves out What made this problem genuinely hard was discipline. There’s no clever trick to save you. You have to understand the formatting rules deeply and implement them cleanly. Solving this felt less like solving a LeetCode problem and more like writing a small formatting engine. This one definitely tested patience but finishing it was extremely satisfying. Hard problem. Big win. On to the next. #LeetCode #DSA #HardProblems #Simulation #ProblemSolving #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
Daily Engineering Practice — Day 23 Focus: • Two Pointers (opposite-direction) • In-place string manipulation • LeetCode 344 — Reverse String Key Insight: • Maintaining the invariant that elements outside the pointers are already reversed enables an O(1) space solution by swapping until pointers meet. Outcome: • Implemented in-place string reversal using left/right pointers • Dry-run verified pointer movement and loop termination (left < right) • Code added to GitHub Code / Practice: GitHub → https://lnkd.in/du4FcjyK #DSA #LeetCode #TwoPointers #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
Day 10 | LeetCode Consistency Solved LeetCode #303 – Range Sum Query (Immutable) Implemented an efficient prefix sum approach to achieve fast query performance and clean logic. Focusing on: Strong DSA fundamentals Optimized time–space trade-offs Writing interview-ready, readable code Consistency in practice builds confidence in problem solving. #LeetCode #DSA #ProblemSolving #SoftwareEngineer #CodingJourney #InterviewPreparation #CareerGrowth #TechSkills #LearningDaily
To view or add a comment, sign in
-
-
Solved LeetCode 658 — Find K Closest Elements This problem isn’t just about picking the nearest numbers — it’s about following the exact ordering rules: absolute difference from x first, and the smaller value in case of a tie. I approached it by pairing each element with its distance from x, then sorting using a custom comparator that mirrors the problem’s constraints. After selecting the first k closest elements, the final step was re-sorting the result to meet the required output format. The key takeaway here is that many array problems fail not because of logic errors, but because tie-breaking conditions are ignored. Being precise with problem definitions matters more than jumping straight to optimization. Correctness first. Optimization next. Consistency always. #LeetCode #DSA #ProblemSolving
To view or add a comment, sign in
-
-
Day 34/100 – #100DaysOfLeetCode 🚀 🧩 Problem: LeetCode 151 – Reverse Words in a String (Easy) 🧠 Approach: Split the string into words, reverse the order of the words, and join them back with a single space. This also automatically removes extra spaces. 💻 Solution: class Solution: def reverseWords(self, s: str) -> str: result = " ".join(reversed(s.split())) return result ⏱ Time | Space: O(n) | O(n) 📌 Key Takeaway: Many string problems become simpler by using built-in string operations like split, reverse, and join. #leetcode #dsa #development #problemSolving #CodingChallenge
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