62 of #100DaysOfCode 🚀 Solved LeetCode 78 – Subsets using a pure recursive (include/exclude) approach in C++. 🔍 Approach: At each index, I make a decision: ✔️ Include the current element in the subset ❌ Exclude the current element This creates a recursion tree exploring all possibilities, and when we reach the end of the array, we store the current subset. 🧠 Core Idea: Pick → Recurse Backtrack → Skip → Recurse Store result when index reaches n #leetcode #cpp #recursion #backtracking #dsa #100DaysOfCode #codingjourney
Solved LeetCode 78 – Subsets using C++ Recursion
More Relevant Posts
-
63 of #100DaysOfCode Solved Subsets II (handling duplicates) today using recursion & backtracking! 💡 Problem Insight: Generating all subsets is easy… until duplicates enter the game. The challenge is to ensure no duplicate subsets in the final answer. 🔍 Approaches Used: 1️⃣ Optimized Recursion + Backtracking (Used ✅) Sort the array first Use include/exclude pattern Skip duplicates in the exclude step using a loop Time: O(2^n) Space: O(n) (recursion stack) #100DaysOfCode #LeetCode #DSA #Recursion #Backtracking #CodingJourney #CPlusPlus #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 72 of #100DaysOfDSA Solved a classic Backtracking problem 🔥 🧩 Problem Solved: LeetCode 77 – Combinations 💡 Key Idea: Generate all possible ways to choose k numbers from 1 to n using Backtracking. 🔍 Approach: Start from a number and pick it Recursively choose next numbers in increasing order Once size becomes k, store the combination Backtrack and try other possibilities ⚡ What I Learned: How recursion builds combinations efficiently Importance of start index to avoid duplicates Backtracking = Choose → Explore → Undo 💻 Language Used: C++ #Day72 #100DaysOfDSA #LeetCode #Cpp #Backtracking #Recursion #CodingJourney
To view or add a comment, sign in
-
-
🚀 130 LeetCode problems solved. From 120 → 130. Focused on Arrays, Binary Search, Linked Lists, Strings & Bit Manipulation. What’s changing? Not just solving problems — but understanding patterns. Consistency is starting to pay off. #LeetCode #DSA #ProblemSolving #Consistency #CodingJourney #KeepLearning
To view or add a comment, sign in
-
-
Day 35/75 🚀 Solved Count Good Nodes in Binary Tree (LeetCode 1448) today! ✅ All 63/63 test cases passed ⚡ Runtime: 91 ms (Beats ~82%) 💾 Memory: 88.34 MB (Beats ~64%) 🔍 Approach: Used DFS (recursion) while tracking the maximum value seen so far on the path. ✔️ Start from root with initial max = root value ✔️ If current node value ≥ max so far → it's a “good node” ✔️ Update max and continue traversal ✔️ Recursively check left and right subtree 💡 Key Learning: Passing state (like max value) in recursion helps solve path-based problems efficiently. No need to store full paths—just keep track of what's important. Consistency + depth thinking = stronger tree skills 🌳🔥 #LeetCode #CPP #DSA #ProblemSolving #CodingJourney #75DaysOfCode #Focused
To view or add a comment, sign in
-
-
60 of #100DaysOfCode Solved LeetCode 704 – Binary Search using a recursive approach in C++ 💻 🔍 Approach: Instead of the usual iterative method, I implemented Binary Search using recursion. The idea is simple but powerful: Find the middle element If it matches the target → return index ✅ If target is smaller → search left half If target is larger → search right half Base case → when search space becomes invalid (left > right) 🧠 This approach reinforces divide-and-conquer thinking and helps build strong fundamentals for advanced problems like trees and recursion-based searches. ⏱️ Complexity: Time: O(log n) Space: O(log n) due to recursion stack #LeetCode #DSA #BinarySearch #Recursion #Cpp #CodingJourney #Placements #TechLearning
To view or add a comment, sign in
-
-
Day 9: LeetCode - 1. Two Sum Back to basics today with one of the most popular problems on LeetCode. The task was simple: given an array and a target, find two indices such that their values add up to the target. My first thought was the brute force approach: Try every pair and check if the sum matches Works fine, but takes O(n²) time Then comes the optimized approach using a hash map: Traverse the array once For each element, check if (target - current value) already exists If yes, we’ve found our answer If not, store the current value with its index This reduces the time complexity to O(n), which is a huge improvement. Takeaway: Many problems that look like nested loops can often be reduced to a single pass using extra space like a hash map. Day 9 completed. #LeetCode #DSA #CodingJourney
To view or add a comment, sign in
-
-
58 of #100DaysOfCode 💻 Solved LeetCode 18 – 4Sum using an optimized approach 🚀 🔹 Approach: Sorted the array and reduced the problem from 4Sum → 2Sum. Fixed two elements (i, j) and used the two-pointer technique (p, q) to find the remaining pair efficiently. 🔹 Complexity: ⏱ Time: O(n³) 📦 Space: O(1) (excluding result) #LeetCode #DSA #Cpp #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 14/100 — LeetCode Challenge Solved Delete Node in a Linked List The twist? 👉 You are not given the head of the list At first, I thought deletion wouldn’t be possible without the previous node. But the trick is: 1) Copy the value of the next node 2) Point current node to next->next 3) Effectively “delete” the next node instead 💡 Key Insight: Instead of deleting the given node directly, we shift values and bypass the next node. 🧠 Time Complexity: O(1) 💾 Space Complexity: O(1) 💡 What I learned: Sometimes problems are not about applying a pattern, but about thinking differently with given constraints. Switching from patterns to concepts now. #LeetCode #DSA #100DaysOfCode #Cpp #LinkedList #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 30/100 — LeetCode Challenge Today's problem: Median of Two Sorted Arrays 🧠 Concept: Binary Search on Partition 💡 Key Idea: Instead of merging arrays, use binary search to partition them such that the left half contains smaller elements and the right half contains larger elements. ⚡ Time Complexity: O(log(min(m, n))) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ One of the most challenging and insightful problems so far. A great exercise in advanced binary search thinking. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
Day 75/150 🚀 LeetCode 101: Symmetric Tree 🧠 Problem Given the root of a binary tree, check whether it is a mirror of itself. 📌 Example Input → root = [1,2,2,3,4,4,3] Output → true 💡 Approach • Use recursion • Compare left subtree with right subtree • Check mirror structure • Continue recursively ⏱ Time Complexity O(n) 📦 Space Complexity O(h) ✅ Result: Accepted ⚡ Runtime: 0 ms (Beats 100%) #Day75 #LeetCode #DSA #BinaryTree #Recursion #CodingJourney #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