Day 9 of #100DaysOfLeetCode 💻✅ Solved Valid Parentheses problem in Java using Stack. Approach: Used a stack to store opening brackets Pushed opening brackets ( { [ into the stack When a closing bracket appeared, checked if it matches the latest opening bracket Returned false if mismatch or stack becomes empty unexpectedly Finally checked if stack is empty to confirm valid parentheses Performance: ✓ Runtime: 3 ms (Beats 87.85%) ✓ Memory: 43.29 MB (Beats 70.02%) Key Learning: ✓ Strengthened understanding of Stack data structure ✓ Improved bracket matching and string traversal logic Learning and improving one problem every single day 🚀 #Java #LeetCode #Stack #ProblemSolving #CodingJourney #100DaysOfCode #DSA
Solved Valid Parentheses in Java with Stack
More Relevant Posts
-
Day 20 of #100DaysOfLeetCode 💻✅ Solved #21. Merge Two Sorted Lists problem on LeetCode in Java. Approach: • Handled edge cases where either list is empty • Used a dummy node to simplify merging logic • Maintained a pointer current to build the new list step-by-step • Compared nodes from both lists and linked the smaller one • Connected any remaining nodes after one list ends • Returned dummy.next as the new head of the merged list Performance: ✓ Runtime: 0 ms (Beats 100% submissions) ✓ Memory: 44.26 MB (Beats 75% submissions) Key Learning: ✓ Strengthened understanding of linked list pointer manipulation ✓ Learned to merge two lists without creating extra nodes ✓ Improved confidence in multi-pointer problems and list traversal Learning one problem every single day 🚀 #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 26 of #100DaysOfLeetCode 💻✅ Solved #203. Remove Linked List Elements on LeetCode using Java. Approach: • Handled edge cases by removing matching nodes from the beginning of the list • Traversed the linked list using a pointer • Checked the next node’s value instead of the current node • If value matched, updated links to skip the node • Maintained in-place modification without using extra data structures Performance: ✓ Runtime: 1 ms (Beats 95.94% submissions) ✓ Memory: 47.62 MB Key Learning: ✓ Improved understanding of linked list pointer manipulation ✓ Learned how to handle head node edge cases carefully ✓ Strengthened in-place deletion logic in singly linked lists Learning one problem every single day 🚀 #Java #LeetCode #DSA #LinkedList #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 27 of #100DaysOfLeetCode 💻✅ Solved #83. Remove Duplicates from Sorted List on LeetCode using Java. Approach: • Utilized the fact that the linked list is already sorted • Traversed the list using a single pointer • Compared current node value with next node value • If duplicate found, skipped the next node by updating links • Continued traversal until reaching the end of the list Performance: ✓ Runtime: 0 ms (Beats 100% submissions) ✓ Memory: 45.30 MB (Beats 85.70% submissions) Key Learning: ✓ Understood how sorting simplifies duplicate removal logic ✓ Strengthened pointer manipulation skills in linked lists ✓ Learned efficient in-place modification without extra space Learning one problem every single day 🚀 #Java #LeetCode #DSA #LinkedList #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 30 of #100DaysOfLeetCode 💻✅ Solved #108. Convert Sorted Array to Binary Search Tree on LeetCode using Java. Approach: • Used Divide and Conquer strategy • Selected the middle element as the root to maintain balance • Recursively built the left subtree using left half of array • Recursively built the right subtree using right half of array • Ensured the tree remains height-balanced at every step Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) ✓ Memory: 45.18 MB (Beats 44.10% submissions) Key Learning: ✓ Understood how sorted arrays can directly map to balanced BST ✓ Strengthened recursion fundamentals in tree construction ✓ Improved understanding of height-balanced binary trees Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearchTree #Recursion #DivideAndConquer #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 25 of #100DaysOfLeetCode 💻✅ Solved #167. Two Sum II – Input Array Is Sorted on LeetCode using Java. Approach: • Used Two Pointer technique since the array is already sorted • Initialized one pointer at the beginning and one at the end • Calculated the sum of both elements • If sum < target, moved left pointer forward • If sum > target, moved right pointer backward • Returned 1-based indices as required in the problem Performance: ✓ Runtime: 1 ms (Efficient with O(n) time complexity) ✓ Memory: Constant extra space (O(1)) Key Learning: ✓ Understood when to apply Two Pointer technique instead of HashMap ✓ Improved ability to optimize space complexity ✓ Strengthened pattern recognition for sorted array problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 31 of #100DaysOfLeetCode 💻✅ Solved #94. Binary Tree Inorder Traversal on LeetCode using Java. Approach: • Used recursion to perform inorder traversal • Followed Left → Root → Right order strictly • Traversed left subtree first before processing current node • Stored node values in a list during traversal • Returned the final list after complete traversal Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) ✓ Memory: 42.76 MB (Beats 98.30% submissions) Key Learning: ✓ Strengthened understanding of tree traversal patterns ✓ Improved clarity on recursion stack behavior ✓ Reinforced difference between preorder, inorder, and postorder traversal Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinaryTree #Recursion #TreeTraversal #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode | Day 35 📌 LeetCode : Minimum Depth of Binary Tree Today I solved the Minimum Depth of Binary Tree problem using Java. The goal was to find the shortest path from the root node to the nearest leaf node. I applied a recursive approach while carefully handling edge cases where one subtree is null. Instead of directly taking the minimum of both sides, I ensured the solution correctly skips null paths to avoid incorrect depth calculations. 📌 Key takeaways: 🔹 Understood the difference between minimum and maximum depth logic 🔹 Learned the importance of handling null child nodes 🔹 Strengthened recursion and tree traversal concepts 🔹 Improved problem-solving accuracy in edge cases This problem helped me think more clearly about tree structures and reinforced the importance of precise base conditions in recursion. #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 36 of #100DaysOfLeetCode 💻✅ Solved #111. Minimum Depth of Binary Tree on LeetCode using Java. Approach: • Used recursive approach to calculate minimum depth • Returned 0 when root is null (base case) • If one subtree is null, avoided taking minimum of 0 (handled edge case carefully) • Returned 1 + minimum depth of valid subtree • Ensured correct handling of skewed trees Performance: ✓ Runtime: 6 ms ✓ Memory: 82.20 MB Key Learning: ✓ Understood difference between minimum depth and maximum depth logic ✓ Learned importance of handling null subtree cases correctly ✓ Improved confidence in solving binary tree recursion problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinaryTree #Recursion #TreeProblems #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 20/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 350. Intersection of Two Arrays II Used sorting + two-pointer technique to efficiently find common elements appearing in both arrays while maintaining correct frequency. ⏱️ Time Complexity: O(n log n + m log m) 📦 Space Complexity: O(min(n, m)) (for storing the intersection) Strengthening understanding of array traversal and two-pointer pattern through consistent practice. 💪 Consistency keeps the progress moving 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 12 of #100DaysOfLeetCode 💻✅ Solved #326. Power of Three problem in Java. Approach: • Checked if the number is less than or equal to zero (not a power of three) • Continuously divided the number by 3 while it was divisible • Verified whether the final value becomes 1 • Avoided recursion and used iteration for better efficiency Performance: ✓ Runtime: 8 ms (Beats 86.60% submissions) ✓ Memory: 46.35 MB Key Learning: ✓ Strengthened understanding of number divisibility logic ✓ Learned efficient validation of power-based numbers ✓ Improved problem-solving using iterative reduction Learning one problem every day 🚀 #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
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