🚀 Day 49 of #100DaysOfCode ✅ Solved: Find the Difference 🔍 What I did: Used a clever XOR bit manipulation technique to identify the extra character between two strings efficiently. 💡 Key Learning: XOR cancels out identical characters Helps find unique elements in linear time Clean and optimal approach without extra space ⚡ Time Complexity: O(n) 📦 Space Complexity: O(1) 🎯 Takeaway: Sometimes the best solutions are not obvious — learning small tricks like XOR can make a big difference in problem solving. #Java #LeetCode #ProblemSolving #CodingJourney #100DaysChallenge #DataStructures #Algorithms
XOR Bit Manipulation for Efficient String Comparison
More Relevant Posts
-
🚀 Day 19/100 — #100DaysOfLeetCode Back to mastering one of the most powerful patterns in DSA — Sliding Window 💻🔥 ✅ Problem Solved: 🔹 LeetCode 1358 — Number of Substrings Containing All Three Characters 💡 Concept Used: Sliding Window + Frequency Tracking 🧠 Key Learning: The goal was to count all substrings containing 'a', 'b', and 'c'. Instead of checking every possible substring, I learned how: Expand the window until all required characters are present. Once valid, every further extension also forms valid substrings. Count substrings efficiently while shrinking the window. This converts a brute-force O(n²) approach into an optimized O(n) solution. ⚡ Big Insight: Sliding Window isn’t just about finding length — it can also be used for counting valid substrings efficiently. Consistency is slowly turning patterns into instincts 🚀 #100DaysOfLeetCode #LeetCode #DSA #SlidingWindow #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 LeetCode Challenge 10/50 🔍 Problem: Merge Sorted Array Today’s problem focused on efficiently merging two sorted arrays without using extra space. 💡 Approach: I used the Two Pointer technique (from the end): Started comparing elements from the back of both arrays Placed the larger element at the end of nums1 Continued this process until all elements were merged ⚡ This approach avoids unnecessary shifting and works in-place. 📊 Complexity Analysis: Time Complexity: O(m + n) Space Complexity: O(1) 📚 Key Learning: Thinking from the end can simplify problems and avoid extra operations. Two-pointer technique is extremely useful for array manipulation problems. Consistency is building confidence 💪 #LeetCode #Algorithms #DataStructures #ProblemSolving #CodingJourney #Java #100DaysOfCode #StudentDeveloper #Learning
To view or add a comment, sign in
-
-
Day 09 of #50DaysOfLeetCode Challenge Just tackled the "Combination Sum" problem! This was a fantastic exercise in backtracking. The challenge is to find all unique combinations of numbers that sum up to a specific target, with the twist that you can use the same number multiple times. Key Insights: Backtracking Power: It’s all about exploring every possible path and "backtracking" as soon as the sum exceeds the target. State Space Tree: Visualizing how the recursion branches out helped me understand how to avoid duplicate combinations while allowing multiple uses of the same element. Decision Making: Learning when to include an element and when to move to the next index is crucial for optimizing the search. Each day, the logic gets sharper and the problems get more interesting! #DataStructures #Algorithms #CodingJourney #Java #Backtracking #LeetCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 20 of my #30DayCodeChallenge: Efficiency through Pruning! Today's challenge was Word Search II-a complex puzzle that tests how you manage massive search spaces. The Logic: 1. Trie Integration: I stored the dictionary in a Trie to check prefixes in O(1) time. 2. DFS & Backtracking: Explored the grid cell by cell, but with a twist... 3. Intelligent Pruning: If a path doesn't match a Trie prefix, the search stops immediately. This turns an exponential problem into something much more manageable. Coding isn't just about finding the answer; it's about finding it before your timer runs out! #Java #DataStructures #Backtracking #Trie #Algorithms #CleanCode #150DaysOfCode
To view or add a comment, sign in
-
-
Day 19 of my #30DayCodeChallenge: Mastering Backtracking! The Problem: Combination Sum. Finding all unique combinations of candidates that sum up to a specific target, where each number can be used an unlimited number of times. The Logic: This problem is a perfect example of how Recursion and Backtracking allow us to explore multiple paths while pruning the ones that don't lead to a solution. 1. State-Space Exploration: I used a recursive approach to explore every possible combination. By passing the current index forward, we ensure we don't pick the same set of numbers in a different order, keeping the results unique. 2. The "Unlimited" Choice: Unlike some problems where you move to the next element immediately, here we have the option to stay on the same element to achieve the "unlimited times" constraint-as long as the remaining target allows it. 3. Backtracking & Pru.. If the current sum exceeds the target. we ston exploring that branch (Backtrack). This keeps the algorithm efficient even as the depth of the recursion grows. One more step toward algorithmic mastery. Onward to Day 20! #Java #Algorithms #DataStructures #Backtracking #ProblemSolving #150DaysOfCode #SoftwareEngineering #LeetCode
To view or add a comment, sign in
-
-
🚀 Day 42 of My LeetCode Journey Today’s problem: Regular Expression Matching This wasn’t just another coding problem — it forced me to think in terms of state transitions and decision trees, not brute force. 🔍 Key Learning: - Pure recursion is not enough → leads to exponential time - Introduced Dynamic Programming (Top-Down with Memoization) - Learned how to break the problem into: - Matching current characters - Handling "*" (zero or more occurrences) 🧠 Core Insight: Instead of trying all possibilities blindly, cache results of subproblems → avoids recomputation. ⚡ Result: - Runtime: 1 ms (Beats 99.99%) - Efficient DP solution with optimal pruning 💡 Takeaway: Hard problems aren’t about syntax — they’re about modeling the problem correctly. #Day42 #LeetCode #DataStructures #DynamicProgramming #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀Day 29 Solved LeetCode Problem #129 – Sum Root to Leaf Numbers Today I worked on a Binary Tree problem that focuses on DFS traversal and number formation from root-to-leaf paths. 🌳 🔹 Problem: Given a binary tree where each node contains digits (0–9), every root-to-leaf path forms a number. The goal is to calculate the total sum of all these numbers. 🔹 Example: Tree: [1,2,3] Paths: 1 → 2 = 12 1 → 3 = 13 Total Sum = 12 + 13 = 25 🔹 Approach: ✔ Use Depth First Search (DFS) ✔ Build the number while traversing the tree ✔ Multiply previous value by 10 and add the current digit ✔ When reaching a leaf node, add the number to the total sum ⏱ Time Complexity: O(n) 📦 Space Complexity: O(h) 💡 Key Learning: This problem helped strengthen my understanding of Binary Tree traversal and how recursive DFS can be used to carry state across nodes. Excited to keep improving my problem-solving skills! 💻🔥 #leetcode #datastructures #algorithms #java #binarytree #coding #softwaredeveloper #codingjourney
To view or add a comment, sign in
-
-
🚀 Day 81 – DSA Journey | Binary Tree Inorder Traversal Continuing my daily DSA practice, today I explored tree traversal and how stacks can simulate recursion. 📌 Problem Practiced: Binary Tree Inorder Traversal (LeetCode 94) 🔍 Problem Idea: Traverse a binary tree in inorder sequence — Left → Root → Right — and return the values of nodes. 💡 Key Insight: Instead of recursion, we can use a stack to iteratively traverse the tree by going as left as possible, then processing nodes and moving right. 📌 Approach Used: • Use a stack to simulate recursion • Start from root and go to the leftmost node • Push nodes while moving left • Pop from stack, process the node • Move to the right subtree and repeat 📌 Concepts Strengthened: • Tree traversal (Inorder) • Stack usage in trees • Iterative vs recursive approaches • Understanding tree structure ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) 🔥 Today’s takeaway: Recursion can always be converted into iteration using stacks — understanding this gives more control over traversal logic. On to Day 82! 🚀 #Day81 #DSAJourney #LeetCode #BinaryTree #Stack #Java #ProblemSolving #Coding #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 Day 84 – DSA Journey | Maximum Depth of Binary Tree Continuing my daily DSA practice, today I focused on understanding tree depth and recursive problem solving. 📌 Problem Practiced: Maximum Depth of Binary Tree (LeetCode 104) 🔍 Problem Idea: Find the maximum depth (or height) of a binary tree — the number of nodes along the longest path from the root to a leaf node. 💡 Key Insight: The depth of a tree depends on its subtrees. At every node, we can recursively calculate the depth of left and right subtrees and take the maximum. 📌 Approach Used: • If the node is null → depth is 0 • Recursively calculate depth of left subtree • Recursively calculate depth of right subtree • Return 1 + max(left, right) 📌 Concepts Strengthened: • Binary tree traversal • Recursion • Divide and conquer approach • Tree height calculation ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(h) (recursion stack) 🔥 Today’s takeaway: Breaking problems into smaller subproblems using recursion makes complex tree problems much easier to handle. On to Day 85! 🚀 #Day84 #DSAJourney #LeetCode #BinaryTree #Recursion #Java #ProblemSolving #Coding #LearningInPublic #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