Solved Combination Sum II problem using recursion and backtracking in C++.

📅 Day 47 of #100DaysOfCode Problem: Combination Sum II (LeetCode 40) Approach: 1️⃣ Sorted the array to handle duplicates easily. 2️⃣ Used recursion to explore each number — either include it or skip it. 3️⃣ Reduced the target as I added elements, and when the target hit 0, that path became a valid combination. 4️⃣ Skipped duplicates using a simple check: if (i > idx && candidates[i] == candidates[i-1]) continue. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Backtracking #Recursion #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #SoftwareEngineering #DailyDSA #CodingJourney #KeepLearning #TechCommunity #Motivation #GrowthMindset

  • text

To view or add a comment, sign in

Explore content categories