#75DaysOfDSA – Day 17 Problem: Letter Combinations of a Phone Number Approach: Implemented using recursion and backtracking Created a keypad mapping array for digit-to-character conversion Generated all possible combinations by exploring each recursive branch Key Learnings: Better understanding of recursion flow and tree structure Handling string immutability during recursive calls Importance of base case and incremental state building Performance: Runtime: 3 ms All test cases passed #DSA #Java #LeetCode #Backtracking #Recursion
Java Phone Number Combinations via Recursion and Backtracking
More Relevant Posts
-
#75DaysOfDSA – Day 13 Practiced recursion with a focus on backtracking. Implemented a recursive function to update an array Traced how values change during recursive calls Understood how backtracking modifies the same array after returning from recursion Key takeaway: Backtracking involves making changes during recursion and reverting them while unwinding the call stack. #DSA #Recursion #Backtracking #Java
To view or add a comment, sign in
-
-
Day 82 – Univalued Binary Tree Solved a problem to determine whether all nodes in a binary tree have the same value using depth-first traversal. Key Learnings: Applied DFS recursion to traverse all nodes in the tree Compared each node’s value with the root value for validation #DSA #Java #BinaryTree #DFS #Recursion #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
Day 74 - Univalued Binary Tree Checking whether all nodes in a binary tree share the same value using recursion. Approach: • Store root value • Traverse the tree recursively • Compare each node with root value • Return false if any mismatch is found Key Insight: Recursion simplifies tree traversal and validation Time Complexity: O(n) #Day74 #LeetCode #Java #CodingPractice #TechJourney #DSA #BinaryTree
To view or add a comment, sign in
-
-
Day 84 - Binary Tree Right Side View Computed the visible nodes when viewing a binary tree from the right side. Approach: • Use level order traversal (BFS) • Process nodes level by level • Add the last node of each level to the result Key Idea: The rightmost node at each level is the visible one Time Complexity: O(n) Space Complexity: O(n) #Day84 #LeetCode #BinaryTree #BFS #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
Day 87 – Binary Tree Paths Solved a problem to find all root-to-leaf paths in a binary tree using DFS recursion. Key Learnings: Used DFS to explore each possible root-to-leaf path Built path strings step by step during traversal Strengthened recursion and tree traversal fundamentals #DSA #Java #BinaryTree #DFS #Recursion #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
🚀 Day 13/150 – Intersection of Two Arrays Find common elements between two arrays 🔍 💡 Approach: Compare elements from both arrays Store only matching values ⚡ Optimized: Use HashSet for faster lookup Time: O(n + m) Space: O(n) 📊 Example: [1,2,2,1], [2,2] → Output: [2] 🎯 Learned: Efficient searching using hashing #Day13 #150DaysOfCode #DSA #Java #LeetCode #CodingJourney #CodingThinker Avinash Jha 🇮🇳
To view or add a comment, sign in
-
-
Day 37 of showing up consistently 💻🔥 Solved Arithmetic Subarrays — a problem that really sharpened my understanding of subarrays and sequence patterns. 💡 Insight: Instead of checking order directly, sorting the subarray and verifying a constant difference makes the solution clean and efficient. ⚡ Runtime: 4 ms (100% 💯) 📊 Small optimizations → Big impact Every day = 1 step closer to mastery. #Day37 #LeetCode #DSA #Java #CodingJourney #Consistency #KeepGrinding
To view or add a comment, sign in
-
-
Day 75 - Count Complete Tree Nodes Finding the total number of nodes in a complete binary tree using recursion. Approach: • Traverse the tree recursively • Count left subtree • Count right subtree • Add 1 for current node Time Complexity: O(n) Space Complexity: O(h) #Day75 #LeetCode #Java #CodingPractice #TechJourney #DSA #BinaryTree
To view or add a comment, sign in
-
-
Day 78 - Binary Tree Level Order Traversal Implemented level-by-level traversal of a binary tree using a queue (BFS). Approach: • Use a queue to process nodes • Traverse level by level • Track size of each level • Store values accordingly Time Complexity: O(n) Space Complexity: O(n) #Day78 #LeetCode #BinaryTree #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 88 - Merge Two Binary Trees Combined two binary trees by summing overlapping nodes. Approach: • If both nodes exist → create new node with sum • If one node is null → use the other node • Recursively merge left and right subtrees Time Complexity: O(n) Space Complexity: O(h) #Day88 #LeetCode #BinaryTree #Recursion #DSA #Java #CodingJourney
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