🌟 Day 63 of 100 Days of LeetCode 🌟 Today’s challenge: LeetCode 101 – Symmetric Tree 🔁 🧩 Problem Summary: Given the root of a binary tree, determine whether it’s a mirror of itself (i.e., symmetric around its center). 🌲✨ 💡 Key Takeaways: 🔹 Strengthened understanding of recursion in binary trees. 🔹 Learned how to compare mirror nodes (left ↔ right). 🔹 Realized that symmetry problems are perfect practice for recursive thinking and structural comparison. 🧠 Approach: 1️⃣ The tree is symmetric if its left and right subtrees are mirror images. 2️⃣ Use a helper function to compare: left.val == right.val left.left == right.right and left.right == right.left 3️⃣ Handle null checks carefully to avoid exceptions. 🔍 This problem beautifully shows how mirror logic + recursion can simplify complex tree checks! #LeetCode #100DaysOfCode #Java #DSA #BinaryTree #ProblemSolving #CodingJourney #Recursion #SymmetricTree
"Day 63: LeetCode 101 - Symmetric Tree Challenge"
More Relevant Posts
-
🌳 Day 62 of 100 Days of LeetCode 🌳 Today’s challenge: LeetCode 226 – Invert Binary Tree 🔄 🧩 Problem Summary: Given the root of a binary tree, invert it — meaning swap the left and right children of every node. Essentially, you’re mirroring the entire tree! 🌲✨ 💡 Key Takeaways: 🔹 Strengthened understanding of tree traversal using recursion. 🔹 Learned how a simple DFS (Depth-First Search) can elegantly solve structural transformations. 🔹 Practiced reasoning about symmetry and recursion base cases. 🧠 Approach: 1️⃣ If the tree is empty, return null. 2️⃣ Recursively invert the left and right subtrees. 3️⃣ Swap the left and right children of the current node. 4️⃣ Return the root once the tree is fully inverted. 🚀 A great example of how recursion simplifies complex problems into smaller, intuitive steps! #LeetCode #100DaysOfCode #Java #DSA #BinaryTree #CodingJourney #Recursion #ProblemSolving
To view or add a comment, sign in
-
-
💻 Day 53 of #LeetCode100DaysChallenge Solved LeetCode 160: Intersection of Two Linked Lists — a problem that tests linked list traversal, pointer manipulation, and logical thinking. 🧩 Problem: Given the heads of two singly linked lists headA and headB, return the node where the two lists intersect. If they do not intersect, return null. 💡 Approach — Two Pointer Technique: 1️⃣ Initialize two pointers a and b at headA and headB. 2️⃣ Traverse both lists. When a pointer reaches the end of one list, redirect it to the head of the other list. 3️⃣ If the lists intersect, the pointers will meet at the intersection node. 4️⃣ If not, both pointers will eventually become null. ⚙️ Complexity: Time: O(N + M) — each list is traversed at most twice. Space: O(1) — no extra data structure used. ✨ Key Takeaways: ✅ Strengthened understanding of pointer redirection and traversal synchronization. ✅ Learned an elegant approach to detect intersection without measuring lengths. ✅ Reinforced logical thinking in linked list-based problems. #LeetCode #100DaysOfCode #Java #LinkedList #Pointers #TwoPointerTechnique #DSA #CodingJourney #WomenInTech #IntersectionOfLinkedLists
To view or add a comment, sign in
-
-
🧠 LeetCode Day 97 — Path Sum (Problem 112) Today’s challenge was about checking whether a binary tree has a root-to-leaf path such that adding up all the values along the path equals a given sum. 🔍 Problem Description: Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that the sum of the node values equals targetSum. Otherwise, return false. 💡 Approach: Traverse the tree recursively. Subtract the current node’s value from targetSum. When a leaf node is reached, check if the remaining sum equals zero. Use Depth First Search (DFS) to explore all paths. 🚀 Key Learnings: Strengthened understanding of recursive tree traversal. Practiced handling base cases in recursion effectively. Improved clarity on root-to-leaf path logic in binary trees. 🌳 #Day97 of #100DaysOfCode Each challenge adds a new layer to my problem-solving skills. Binary tree problems like this sharpen the recursive mindset — thinking from root to leaf and back up! 💪 #LeetCode #CodingChallenge #Java #100DaysOfCode #BinaryTree #ProblemSolving #Recursion
To view or add a comment, sign in
-
-
✨ Day 54 of 100: Reverse Nodes in k-Group ✨ Today’s challenge was LeetCode 25 – Reverse Nodes in k-Group 🔁 🧩 Problem: Given a linked list, reverse the nodes of the list k at a time and return its modified list. If the number of nodes is not a multiple of k, the remaining nodes should remain as-is. 💡 Key Takeaways: 🔹 Strengthened understanding of linked list manipulation and pointer handling. 🔹 Practiced breaking the list into segments of size k and reversing each group independently. 🔹 Learned how to manage head and tail connections between reversed and remaining parts. 🔹 Reinforced problem-solving using dummy nodes to simplify list operations. 🧠 Approach: 1️⃣ Count the total nodes to know how many full groups of k exist. 2️⃣ For each group, reverse k nodes iteratively. 3️⃣ Connect the reversed group to the next segment. 🧭 Insight: This problem beautifully illustrates how iteration with precise pointer movement can replace recursion while still achieving elegant reversals in linked lists. #100DaysOfCode #Day53 #LeetCode #Java #LinkedList #CodingJourney #DSA #ProblemSolving
To view or add a comment, sign in
-
-
💻 Day 65 of #LeetCode100DaysChallenge Solved LeetCode 219: Contains Duplicate II — a smart problem involving hashing and sliding window logic. 🧩 Problem: Given an integer array nums and an integer k, return true if there exist two distinct indices i and j such that: nums[i] == nums[j], and |i - j| <= k. 💡 Approach — HashMap (Index Tracking): 1️⃣ Use a HashMap to store each number and its most recent index. 2️⃣ For every element nums[i]: If it’s already in the map and i - map.get(nums[i]) <= k, return true. Otherwise, update the index in the map. 3️⃣ If no pair found, return false. ⚙️ Complexity: Time: O(N) — single pass through the array. Space: O(N) — for storing indices in the map. ✨ Key Takeaways: ✅ Strengthened understanding of index-based distance checking. ✅ Efficiently applied hash maps for tracking element positions. ✅ Learned how to implement O(N) duplicate checks with window constraints. #LeetCode #100DaysOfCode #Java #HashMap #SlidingWindow #DSA #ProblemSolving #CodingChallenge #WomenInTech
To view or add a comment, sign in
-
-
🚀 LeetCode 150 – Lowest Common Ancestor of a Binary Tree 🌳 A recursion-based problem from the LeetCode 150 list! The goal: find the lowest common ancestor (LCA) of two given nodes in a binary tree. 🔹 Approach If the current node is null, return null. If the node matches p or q, return it. Recursively check left and right subtrees. If both return non-null → current node is the LCA. Otherwise, propagate the non-null result upward. 💡 Time: O(N) | Space: O(H) #LeetCode150 #DSA #Java #Recursion #BinaryTree #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
✨ Day 61 of 100: Same Tree ✨ Today’s challenge was LeetCode 100 – Same Tree 🌳 The task: Given two binary trees, determine if they are the same — meaning both structure and node values are identical. 💡 Key Takeaways: 🔹 Strengthened understanding of recursive tree traversal (checking left and right subtrees). 🔹 Practiced comparing tree nodes carefully — both value and structure. 🔹 Reinforced concepts of DFS (Depth-First Search) and base case handling in recursion. 🧠 Approach: 1️⃣ If both nodes are null, return true. 2️⃣ If only one is null, return false. 3️⃣ Check if values are equal, and then recursively verify left and right subtrees. 🌱 This problem was a great refresher on recursion fundamentals and tree comparison logic! #LeetCode #100DaysOfCode #Day61 #Java #DSA #CodingChallenge #BinaryTree #Recursion #DepthFirstSearch
To view or add a comment, sign in
-
-
✅Day 41 : Leetcode 153 - Find Minimum in Rotated Sorted Array #60DayOfLeetcodeChallenge 🧩 Problem Statement Given a sorted array that has been rotated at an unknown pivot, find the minimum element in the array. The array contains unique elements, and the solution must run in O(log n) time. 💡 My Approach I used a binary search technique to efficiently find the minimum element. I maintained two pointers, low and high. At each step, I calculated the mid-point. If the left part (nums[low] to nums[mid]) was sorted, I updated my answer with the smaller of nums[low] and current ans, and moved low to mid + 1. Otherwise, I updated my answer with nums[mid] and moved high to mid - 1. This approach ensures we keep narrowing the search space toward the minimum element. ⏱️ Time Complexity O(log n) — Because the search space is halved in each iteration. #BinarySearch #LeetCode #RotatedSortedArray #DSA #CodingPractice #Java #ProblemSolving
To view or add a comment, sign in
-
-
🧮 Day 30 of My #100DaysOfLeetCode Challenge ✅ Problem: Find Target Indices After Sorting Array 🧩 Difficulty: Easy 📂 Category: Array / Counting ⚡ Runtime: 0 ms (Beats 100%) 💾 Memory: 44.54 MB 🔹 Approach: Instead of sorting, I used counting logic to find the number of elements smaller than the target (lessThan) and the count of target elements (count). The resulting indices are then [lessThan, lessThan + 1, ..., lessThan + count - 1]. This avoids unnecessary sorting and keeps the solution O(n). 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) ✨ Learnings: How counting-based reasoning can replace sorting for index-based problems. Focused on optimization and problem pattern recognition. 📈 Progress: Day 30 ✅ | 70 days remaining 🚀 💭 “Optimization is not about doing more — it’s about doing smarter.” #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving #CodingChallenge #Consistency
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