🎯 Day 67 of #100DaysOfCode 📌 Problem: Combination Sum Today's challenge was all about finding all unique combinations of candidates where the chosen numbers sum to a given target. The same number can be used unlimited times, and combinations must be unique. 🧠 Approach: Used dynamic programming with a 3D list structure dp[t] stores all combinations that sum to target t Iterated through candidates and built combinations from smaller sums Extended each valid combination by adding current candidate 📊 Stats: ✅ 160/160 test cases passed ⚡ Runtime: 5 ms | Beats 10.10% 💾 Memory: 46.71 MB | Beats 5.88% 📝 Takeaway: This problem highlighted the trade-off between intuitive DP solutions and optimization. While the approach works, there's room for improvement in both runtime and memory efficiency. Backtracking might be a more elegant solution here! 🔗 Problem: Combination Sum 🏷️ #LeetCode #CodingChallenge #Java #DynamicProgramming #Backtracking #Algorithms #TechJourney #ProblemSolving
Aditya Singhal’s Post
More Relevant Posts
-
Day 10 of LeetCode Today I tackled one of the classic dynamic programming challenges — Regular Expression Matching. The problem involves matching a string with a pattern that includes: matches any single character matches zero or more of the preceding element Approach: Built a 2D DP table where dp[i][j] represents whether substring s[0..i-1] matches p[0..j-1] Carefully handled * with two cases: Zero occurrence One or more occurrences Initialized edge cases for patterns like a*, a*b* Result: Accepted with optimal performance! This problem really strengthens understanding of: Pattern matching DP state transitions Edge case handling Consistency is key — one hard problem at a time #LeetCode #DataStructures #Algorithms #DynamicProgramming #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀100 Days of Code - Day 10 Today I worked on a classic Regular Expression Matching problem. Given a string s and a pattern p, determine if the entire string matches the pattern. The pattern supports: • . → matches any single character • * → matches zero or more of the preceding element Example: s = "ab" p = ".*" Output → true This problem is a great exercise in Dynamic Programming and pattern matching concepts. #Java #Algorithms #DataStructures #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
Day 37/100 🚀 | #100DaysOfDSA Solved Reverse String by Character Type – LC 3823 This problem required reversing characters in a string — but with a twist. Letters and special characters had to be reversed within their own groups while keeping their original positions relative to each other. Example idea: Letters reverse among letters, special characters reverse among specials. My Approach: • Converted the string to a character array for easier traversal. • Used two stacks — one for letters and one for special characters. • First pass: pushed characters into their respective stacks. • Second pass: rebuilt the string by popping from the correct stack depending on the character type. Time Complexity: O(n) Space Complexity: O(n) Key Learning: Breaking a problem into categories can simplify the logic significantly. Once characters were separated by type, reconstructing the result became straightforward. Small problems. Clear thinking. Consistent progress. 💪 #100DaysOfCode #LeetCode #DSA #Java #Strings #Stacks #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 56 of 365 🚀 Maximum Product of Two Elements in an Array 🧠 Simple problem. Clean logic. Zero extra space. The task: find two largest numbers in an array, subtract 1 from each, multiply that's your answer. The approach? Track the top 2 values in a single pass. No sorting. No extra array. Just two variables doing all the work. Time: O(n) | Space: O(1) The real lesson here isn't the problem itself it's the habit of asking "do I really need to sort this?" before reaching for Arrays.sort(). Most of the time, a linear scan is enough. 🎯 Day 56. Showing up. ✅ #365DaysDSAChallenge #DSA #LeetCode #Java #CodingChallenge #BackendDeveloper #LinkedInLearning
To view or add a comment, sign in
-
-
🚀 Day 14/100 – #100DaysOfCode Challenge 🔍 Problem Solved: Single Number (LeetCode 136) Today’s problem was about finding the element that appears only once in an array where every other element appears twice. 💡 Key Insight: Used the power of XOR (^) bit manipulation Same numbers cancel out → a ^ a = 0 XOR with 0 gives the number → a ^ 0 = a 👉 By XOR-ing all elements, duplicates vanish, leaving the unique number! ⚡ Approach: Traverse the array once Apply XOR on each element Result = single number ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) 🔥 What I Learned: Bit manipulation can simplify problems drastically XOR is super powerful for pairing problems #Day14 #CodingChallenge #Java #DataStructures #Algorithms #BitManipulation #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Day 15 of Programming Multiple Arrays Today I worked on Multiple Arrays and finding the Largest Repeating Element in a Sorted Array. 🔹 Multiple Arrays Learned how to handle and traverse more than one array in a program. This helps when comparing data, merging arrays, or solving problems involving multiple datasets. 🔹 Largest Repeating Element in a Sorted Array Since the array is sorted, repeating elements appear next to each other. By iterating through the array and counting occurrences, we can efficiently identify the largest element that appears more than once. 💡 What I Practiced Traversing multiple arrays Comparing elements across arrays Counting occurrences in sorted arrays Identifying repeating elements using loops and conditions 🧠 Example Problem Practiced Find the largest repeating element in a sorted array. Example: Array → 1 2 2 3 3 3 4 5 Output → 3 (largest element that repeats) #Day15 #ProgrammingJourney #Java #CodingPractice #ProblemSolving
To view or add a comment, sign in
-
-
Day 5/100 – LeetCode Challenge Problem: Word Search Today’s challenge was a classic 2D Matrix + DFS + Backtracking problem. Problem Summary: Given a 2D board of characters and a word, determine if the word exists in the grid. Rules: Adjacent cells = horizontal or vertical A cell cannot be reused in the same path Approach Used: Traverse every cell as a starting point Apply Depth First Search (DFS) Mark visited cells temporarily Backtrack after exploring all 4 directions Core idea: Base case → If index == word.length() → return true Boundary check + character match validation Mark visited → Explore → Restore (Backtracking) Key Concepts Practiced: Recursion Backtracking 2D matrix traversal State modification & restoration Time Complexity: O(m × n × 4^L) (L = length of word) This problem reinforced an important lesson: Backtracking is about exploring possibilities and undoing choices efficiently. #100DaysOfCode #LeetCode #DSA #Java #Backtracking #SoftwareEngineerJourney #CodingInterview
To view or add a comment, sign in
-
-
Day 3 of my #30DayCodeChallenge: Handling "Infinite" Numbers! The Problem: Multiply Strings. The Logic: I went back to the basics-literally back to grade school. Since I couldn't rely on the * operator for these massive strings, I simulated the Long Multiplication algorithm: Digit-by-Digit: I broke the strings down, converted characters to integers, and multiplied them one by one. The Index Secret: The product of digits at positions i and j always lands at index (i+j+1). The Carry Phase: I handled the carries in a separate pass to keep the code clean and readable ensuring every digit remains between O and 9. Optimization Highlight: Using a StringBuilder for the final conversion instead of simple String concatenation. This avoids creating multiple immutable String objects in memory, keeping the time complexity at O(m x n). Small steps every day lead to big results. Onward to Day 4! #Java #CodingChallenge #ProblemSolving #Algorithms #StringManipulation #SoftwareDevelopment #150DaysOfCode
To view or add a comment, sign in
-
-
Day 65: The "One-Liner" Win 🎯 Problem 1784: Check if Binary String Has at Most One Segment of Ones Today was a lesson in simplifying logic. The challenge: check if a binary string contains more than one contiguous segment of '1's, given that the string starts with '1'. The Strategy: • Observation: If there are multiple segments of '1's, they must be separated by at least one '0'. • The Pattern: In a string starting with '1', any "new" segment of ones would look like "01" somewhere in the string. • The Execution: A simple !s.contains("01") handles the entire check. Sometimes we hunt for complex algorithms when a single string method is the ultimate counter. Clean, readable, and passed all test cases. 🚀 #LeetCode #Java #StringManipulation #Coding #Efficiency #DailyCode
To view or add a comment, sign in
-
-
Day 33 of Daily DSA 🚀 Solved LeetCode 58: Length of Last Word ✅ Problem: Given a string s, return the length of the last word (a sequence of non-space characters). Approach: First, trim() the string to remove trailing spaces Traverse the string from the end Count characters until a space is encountered 💡 Key Insight: Instead of splitting the string (which uses extra space), we can simply iterate backwards for an efficient solution. ⏱ Complexity: • Time: O(n) • Space: O(1) 📊 LeetCode Stats: • Runtime: 0 ms (Beats 100%) ⚡ • Memory: 43.17 MB A simple yet important problem to strengthen string traversal techniques. #DSA #LeetCode #Java #Strings #ProblemSolving #CodingJourney #Consistency
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