🎯 Day 68 of #100DaysOfCode 📌 Problem: Combination Sum II Today's challenge was a twist on the classic combination sum problem! Each number in candidates can only be used once, and the solution set must not contain duplicate combinations. 🧠 Approach: Sorted the array first to handle duplicates efficiently Used recursion with backtracking Skipped duplicate elements to avoid repeated combinations Explored all possible combinations by picking/unpicking elements 📊 Stats: ✅ 176/176 test cases passed ⚡ Runtime: 6 ms | Beats 73.38% 💾 Memory: 45.61 MB | Beats 19.56% 📝 Takeaway: The key challenge was avoiding duplicate combinations while ensuring each element is used at most once. Sorting + skipping duplicates during recursion made this elegant. Memory optimization is the next frontier! 🔗 Problem: Combination Sum II 🏷️ #LeetCode #CodingChallenge #Java #Backtracking #Recursion #Algorithms #DuplicateHandling #TechJourney #Programming
Aditya Singhal’s Post
More Relevant Posts
-
🚀 Day - 24/100 : 📌 Problem : Binary Number with Alternating Bits 🔗 Problem Link : https://lnkd.in/gCDJXjEK 💡 Approach The goal is to check whether adjacent bits in the binary representation are different (i.e., 101010... pattern). Extract the last bit of the number using n & 1. Right shift the number using n >> 1 to move to the next bit. Again extract the next bit using n & 1. Compare the two bits: If they are equal, the number does not have alternating bits → return false. Continue this process until all bits are checked. If no two adjacent bits are the same, return true. #100DaysOfLeetCode #LeetCode #DSAWithKunal #Algorithms #Java #BitManipulation #CodingPractice #ProblemSolving #DeveloperJourney #Programming
To view or add a comment, sign in
-
-
🔥 𝗗𝗮𝘆 𝟴𝟭/𝟭𝟬𝟬 — 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 𝟳𝟴. 𝗦𝘂𝗯𝘀𝗲𝘁𝘀 | 𝗠𝗲𝗱𝗶𝘂𝗺 | 𝗝𝗮𝘃𝗮 Given an integer array, return all possible subsets (the power set) — no duplicates allowed. 𝗠𝘆 𝗮𝗽𝗽𝗿𝗼𝗮𝗰𝗵 — 𝗕𝗮𝗰𝗸𝘁𝗿𝗮𝗰𝗸𝗶𝗻𝗴: ✅ At each index, make a choice: include or exclude ✅ Recurse with the element added → then backtrack (remove it) ✅ Recurse again without the element ✅ Base case: when index == nums.length, save the current subset This explores every branch of the decision tree, giving us all 2ⁿ subsets cleanly. 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆: ⏱ Time: O(n × 2ⁿ) — 2ⁿ subsets, each copied in O(n) 📦 Space: O(n) recursion depth Backtracking is one of those patterns that feels magical once it clicks — the "add → recurse → remove" rhythm is the heart of so many classic problems. 📂 𝗙𝘂𝗹𝗹 𝘀𝗼𝗹𝘂𝘁𝗶𝗼𝗻 𝗼𝗻 𝗚𝗶𝘁𝗛𝘂𝗯: https://lnkd.in/gZmezt_g 19 more days to go. Almost there! 💪 #LeetCode #Day81of100 #100DaysOfCode #Java #DSA #Backtracking #Recursion #CodingChallenge #Programming
To view or add a comment, sign in
-
🚀 Day 85 of #100DaysOfCode Today I practiced a simple yet useful array prefix minimum problem. 🔹 Problem Given an array cost, return a new array where each element represents the minimum cost encountered from the start up to that index. 🔹 Approach I used a running minimum technique: Maintain a variable min to track the smallest value seen so far. Traverse the array. Update min using Math.min(min, cost[i]). Store the current minimum in the result array. 🔹 Time Complexity ⏱ O(n) – Single pass through the array. 🔹 Space Complexity 📦 O(n) – For storing the result array. 🔹 Key Learning This is a classic prefix computation pattern where we keep track of information while traversing the array. #DSA #Java #Programming #CodingJourney #100DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 10 – How Arrays Really Work in Java Today I went beyond basic syntax and understood how arrays actually work internally in Java. 🔎 What I explored: ✔️ How arrays are stored in contiguous memory locations ✔️ How index-based access works (0-based indexing) ✔️ How array size is fixed after creation ✔️ How reference variables point to array objects in memory ✔️ Time complexity of accessing elements – O(1) Understanding the internal working of arrays helped me realize why they are fast for accessing elements but limited when it comes to resizing. This concept is very important before moving to advanced data structures like ArrayList, LinkedList, and more. 🙏 Special thanks to Aditya Tandon Sir for explaining the internal memory concept so clearly. #Day10 #Java #Arrays #DataStructures #LearningJourney #Programming #Coding #JavaDeveloper
To view or add a comment, sign in
-
-
Programming language tier list for algo trading Tier 1 Python for research, C plus plus for low latency, C sharp for NinjaTrader ecosystem, Java for large systems. Tier 2 Rust and Go for robust services. Tier 3 JavaScript for tooling, R for stats. Pick based on execution needs.
To view or add a comment, sign in
-
Day 74/100: LeetCode Challenge - Letter Combinations of a Phone Number 📱 Today I solved the classic backtracking problem - generating all possible letter combinations from a phone number! Problem: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent (just like the old phone keypads). Example: Input: "23" → Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] My approach: Used backtracking to explore all possible combinations Mapped each digit to its corresponding letters (2→abc, 3→def, etc.) Built combinations recursively by trying each letter for the current digit Results: ✅ Runtime: 3 ms (beats 32.71%) ✅ Memory: 48.65 MB (beats 26.99%) Key takeaway: Backtracking is a powerful technique for generating all combinations/permutations. The key is to build the solution incrementally and backtrack when we've explored a complete path. This problem is a perfect example of when recursion shines! #100DaysOfCode #LeetCode #Java #Backtracking #CodingChallenge #ProblemSolving #Day73 #Programming
To view or add a comment, sign in
-
-
Today let's practice one of the strongest foundations in Java — Arrays. From basics like: ✔ Finding even numbers ✔ Reversing an array ✔ Sum & average To logic-building concepts like: ✔ Largest & smallest element ✔ Linear Search (Brute Force) ✔ Selection Sort Arrays may look simple… But they build real problem-solving skills and algorithmic thinking. I’ve uploaded all the programs here: https://lnkd.in/g_ZW9aqq Swipe through the carousel → Practice → Improve #Java #JavaFullStack #Arrays #CodingPractice #DSA #LearningInPublic #Programming
To view or add a comment, sign in
-
LeetCode Problem || Find All Possible Stable Binary Arrays I(3129)🚀. Today I worked on the problem "Number of Stable Arrays". A stable array is an array consisting of 0s and 1s where we cannot place more than limit consecutive identical elements. 🔹 Key Idea To solve this, I used Recursion + Dynamic Programming (Memoization). The state of the problem depends on: Remaining zeros Remaining ones The last bit placed in the array The current streak (how many times the same bit has appeared consecutively) So the stored results in a 4D DP array Consistent practice on data structures and algorithms is helping me strengthen my problem-solving skills every day. #LeetCode #DynamicProgramming #Recursion #CodingPractice #DSA #Java
To view or add a comment, sign in
-
-
🚀 Day 10 of My Programming Journey – Introduction to Array Traversal Today, I focused on understanding the fundamentals of Array Traversal in Java a core concept that plays a major role in problem-solving and data handling. 🔹 1️⃣ Array Traversal Array traversal means accessing each element of an array one by one. It helps in reading, processing, and analyzing data stored inside arrays. Understanding traversal is important because almost every array-based problem starts here. 🔹 2️⃣ Count Elements in an Array I learned how to logically determine the number of elements present in an array. This concept strengthens understanding of: Array size Loop execution Basic counting logic 🔹 3️⃣ Finding the Maximum Element Index Another important program was identifying the index of the maximum value in an array. This improves: Comparison logic Decision-making using conditions Tracking positions while iterating ✅ Stronger understanding of loops ✅ Better clarity on array structure ✅ Improved logical thinking ✅ Foundation for searching and sorting algorithms #Day10 #Java #ArrayTraversal #ProgrammingJourney #KeepLearning
To view or add a comment, sign in
-
-
Day 75/100: LeetCode Challenge - Count and Say 🔢 Today I tackled the "Count and Say" sequence problem - a fascinating exercise in string manipulation and pattern recognition! Problem: The count-and-say sequence starts with "1". Each subsequent term is generated by "saying" the previous term - counting consecutive digits and saying the count followed by the digit. Example: 1 → "one 1" → "11" 11 → "two 1s" → "21" 21 → "one 2, one 1" → "1211" My approach: Started with base case "1" Iteratively built each next term by traversing the current string Counted consecutive identical characters and appended count + digit to StringBuilder Used StringBuilder for efficient string concatenation Results: ✅ Runtime: 3 ms (beats 72.74%) ✅ Memory: 42.90 MB (beats 84.80%) Key takeaway: Sometimes the most straightforward iterative approach is the best! This problem teaches the importance of careful string traversal and StringBuilder usage for optimal performance. The key was recognizing the pattern: each new string is just a "run-length encoding" of the previous one. #100DaysOfCode #LeetCode #Java #StringManipulation #CodingChallenge #ProblemSolving #Day74 #Programming
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