📅 Day 36 of #100DaysOfCode Today’s challenge was one of the most interesting and tricky recursion problems! Problem: Regular Expression Matching (LeetCode #10) 🔍 Approach: The goal is to determine if a given string text matches a pattern that includes: . → Matches any single character * → Matches zero or more occurrences of the preceding element 1️⃣ Used recursion to check character-by-character matches. 2️⃣ For each step: Checked if the current characters match (text[0] == pattern[0] or pattern[0] == '.'). If the next pattern character is *, explored two possibilities: Skip * and the previous character (zero occurrence). Use * to match one or more occurrences (consume one character from text). 3️⃣ Continued recursively until the entire text and pattern were checked. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #DailyDSA #SoftwareEngineering #CodingJourney #LearningInPublic #TechCommunity #KeepLearning #Recursion #GrowthMindset #Motivation
Solved LeetCode #10: Regular Expression Matching with Recursion
More Relevant Posts
-
📅 Day 41 of #100DaysOfCode Problem: Merge k Sorted Lists (LeetCode 23) This one was all about optimization and clean recursion. Instead of merging lists one by one, I used a divide and conquer approach merge them in pairs, just like merge sort. Approach: 1️⃣ If there’s only one list, return it - base case. 2️⃣ Split the range of lists into two halves using recursion. 3️⃣ Merge both halves using a helper function that merges two sorted lists. 4️⃣ Keep dividing until everything is combined into one sorted list. #100DaysOfCode #LeetCode #DSA #Cplusplus #ProblemSolving #DivideAndConquer #Recursion #CodingChallenge #Algorithms #Programming #CodeNewbie #DeveloperLife #LearningInPublic #KeepLearning #SoftwareEngineering #TechCommunity #DailyDSA #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 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
To view or add a comment, sign in
-
-
📅 Day 46 of #100DaysOfCode Problem: Combinations (LeetCode 77) Approach: 1️⃣ Used recursion to build combinations incrementally. 2️⃣ For every number, we have two choices — include it or skip it. 3️⃣ Once we’ve picked k numbers, added that combination to the result. 4️⃣ Used backtracking (pop_back) to explore the next possibility cleanly. #100DaysOfCode #LeetCode #DSA #Backtracking #Recursion #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #SoftwareEngineering #CodingJourney #DailyDSA #KeepLearning #GrowthMindset #Motivation #TechCommunity
To view or add a comment, sign in
-
-
📅 Day 28 of #100DaysOfCode 🚀 Problem: 49. Group Anagrams (LeetCode) Approach: -> For each string, sort its characters — the sorted version acts as a unique key for its anagram group. -> Store all words with the same sorted key inside a hash map (unordered_map<string, vector<string>>). -> After processing all words, collect all grouped values from the map into a result vector. ->This leverages hashing + sorting for efficient grouping — O(n * k log k) where k is average string length. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #DataStructures #Hashing #StringManipulation #CodingCommunity #Programming #DeveloperLife #LearnToCode #TechCommunity #DailyDSA #CodeNewbie #SoftwareEngineering #CodingJourney #Consistency #KeepLearning #LearningInPublic #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 Day 35 of #100DaysOfCode Problem: Search in Rotated Sorted Array II (LeetCode 81) Approach: 1️⃣ First, handled duplicates by skipping consecutive equal elements from both ends to avoid confusion while finding the rotation point. 2️⃣ Used a modified binary search to find the pivot (the smallest element’s index) — this separates the rotated parts of the array. 3️⃣ Performed binary search on both halves — before and after the pivot — to check where the target lies. 4️⃣ Returned true if found in either part, else false. #100DaysOfCode #LeetCode #BinarySearch #RotatedArray #ProblemSolving #Algorithms #DSA #Cplusplus #CodingChallenge #Programming #DeveloperLife #CodeNewbie #DailyDSA #TechCommunity #KeepLearning #SoftwareEngineering #LearningInPublic #Motivation
To view or add a comment, sign in
-
-
📅 Day 31 of #100DaysOfCode Problem: Reverse Pairs (LeetCode 493) Approach: 1️⃣ Divide the array using merge sort to count pairs efficiently. 2️⃣ Count cross-pairs where nums[i] > 2 * nums[j] while merging. 3️⃣ Merge the halves back in sorted order to maintain correct comparisons. 4️⃣ Sum up counts from left, right, and cross halves for the final result. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #DailyDSA #SoftwareEngineering #CodingJourney #LearningInPublic #TechCommunity #KeepLearning #DivideAndConquer #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 Day 48 of #100DaysOfCode Problem: Search in Rotated Sorted Array II (LeetCode 81) Approach: 1️⃣ First, used a pivot function to find the smallest element’s index, skipping duplicate values on both sides. 2️⃣ Once the pivot was found, split the array into two sorted parts. 3️⃣ Applied normal binary search on both halves to find the target. 4️⃣ Combined both steps to handle rotations and duplicates efficiently. #100DaysOfCode #LeetCode #DSA #ProblemSolving #BinarySearch #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #SoftwareEngineering #CodingJourney #DailyDSA #KeepLearning #TechCommunity #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
💻 Day 34 of #100DaysOfLeetCode Today’s Challenge: 83. Remove Duplicates from Sorted List 🔹 Problem: Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Key Insight: Because the list is already sorted, duplicates will always be adjacent—this allows us to remove them in a single pass using pointer manipulation. 🔍 Approach: Traverse the list using a pointer. Compare current node with the next node. If values are equal → skip the next node by linking to the next of next. Otherwise → move forward. 🕒 Time Complexity: O(n) 📦 Space Complexity: O(1) ✨ Key Takeaway: This problem reinforces the importance of pointer manipulation and understanding how memory references work in linked lists. A simple check can eliminate duplicates efficiently without using extra space. Link:[https://lnkd.in/gsjVxHXM] #100DaysOfLeetCode #Day34 #LeetCode #ProblemSolving #DSA #Algorithms #LinkedList #CodingChallenge #CodeNewbie #InterviewPreparation #SoftwareEngineering #Programming #CodingCommunity #TechCareers #CareerGrowth #ArjunInfoSolution
To view or add a comment, sign in
-
-
📅 Day 33 of #100DaysOfCode Problem: Basic Calculator (LeetCode 224) Approach: 1️⃣ Parsed the string character by character, keeping track of current number, sign, and result. 2️⃣ When encountering '+' or '-', added the previous number to the result and reset the current number. 3️⃣ Used a stack to handle parentheses — pushed the current result and sign when '(' was found, then restored them after ')'. 4️⃣ Carefully computed the final result by adding the last pending number after traversal. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Stack #Cplusplus #CodingChallenge #Algorithms #Math #CodeNewbie #Programming #SoftwareEngineering #CodingJourney #TechCommunity #DeveloperLife #KeepLearning #LearningInPublic #Motivation
To view or add a comment, sign in
-
-
🚀 Day 16 of my 120 Days LeetCode Challenge! 🧩 Problem 16: 3Sum Closest (Medium) The problem statement is: Given an integer array nums and an integer target, find three integers in nums such that their sum is closest to the target. Return the sum of these three integers. You may assume that each input would have exactly one solution. 💡 Example: Input: nums = [-1, 2, 1, -4], target = 1 Output: 2 Explanation: The sum closest to 1 is 2 (-1 + 2 + 1 = 2). ⚙️ Algorithm Used: For this problem, I implemented a two-pointer approach after sorting the array. Here’s the step-by-step logic: Sort the array to arrange elements in increasing order. Fix one element and then use two pointers — one starting from the next index (left) and another from the end (right). Calculate the sum of these three elements. If the current sum is closer to the target than the previously recorded closest sum, update the closest sum. Move pointers accordingly: If currentSum < target, move left++ (to increase sum). If currentSum > target, move right-- (to decrease sum). If an exact match is found, return it immediately since it’s the best possible. ⏱ Time Complexity: O(n²) 💾 Space Complexity: O(1) 🔥 This problem helped me strengthen my understanding of sorting and two-pointer techniques for array-based problems. I’m steadily progressing with consistency and learning something new every day! 💪 #Day16 #LeetCode #CodingChallenge #Cplusplus #DSA #ProblemSolving #TwoPointer #LearningJourney #100DaysOfCode #Programming
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