Day 32/100 | #100DaysOfDSA 🌳✨ Today’s problem: Symmetric Tree A tree is symmetric if the left subtree is the mirror of the right subtree. Approach: • Use two queues • Compare left and right nodes together • Check mirror conditions at every step If values mismatch → Not symmetric. Time Complexity: O(n) Space Complexity: O(n) Big takeaway: Symmetry in trees is just mirror comparison at every level. Understanding trees deeper every day. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
Symmetric Tree Problem: Mirror Comparison
More Relevant Posts
-
Day 33/100 | #100DaysOfDSA 🌳💻 Today’s problem: Binary Tree Postorder Traversal Postorder follows a simple rule: Left → Right → Root Approach: • Use recursion • Traverse left subtree • Traverse right subtree • Add the root at the end This ensures children are processed before the parent. Time Complexity: O(n) Space Complexity: O(h) (recursion stack) Big takeaway: Tree traversals are just different visiting orders — mastering them builds strong tree intuition. Stacking tree patterns daily. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
Day 36/100 | #100DaysOfDSA 🌳💻 Today’s problem: Subtree of Another Tree The task is to determine whether one binary tree is a subtree of another. A subtree must match both the structure and node values of the original tree. Approach: • Traverse the main tree using recursion • At each node, check if the subtree rooted there matches the given subRoot • Use a helper function to compare both trees for structural and value equality • If no match is found, continue checking the left and right subtrees This works by combining two recursive checks: 1️⃣ Search for a potential matching root 2️⃣ Verify if both trees are identical Time Complexity: O(n × m) Space Complexity: O(h) Big takeaway: Complex tree problems often break down into combining simpler tree problems — in this case, tree traversal + same tree comparison. Building stronger tree problem-solving patterns every day. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
Day 5 – Longest Consecutive Sequence. Today's problem focused on finding the longest consecutive sequence in an unsorted array, which helps strengthen understanding of sorting, edge cases, and sequence tracking. Approach Step 1 – Sort the Array Step 2 – Traverse the Array While iterating: 1️⃣ If elements are equal → skip duplicates 2️⃣ If nums[i] == nums[i-1] + 1 → increase sequence count 3️⃣ Otherwise → reset the count. Step 3 – Track Maximum Length. Github Code :- https://lnkd.in/gF8DqckJ #LeetCode #DSA #StriverA2Z #CodingJourney #Java #Arrays #ProblemSolving #CodingPractice #SoftwareEngineering #TechInterviewPrep #100DaysOfCode #DeveloperJourney #ComputerScience
To view or add a comment, sign in
-
-
Day 14/100 – LeetCode Challenge Problem: Linked List Cycle II Today’s problem focused on detecting the node where a cycle begins in a linked list. Approach: Used Floyd’s Cycle Detection Algorithm (Slow & Fast pointers). Move slow by one step and fast by two steps. If they meet, a cycle exists. Reset slow to head. Move both slow and fast one step at a time. The node where they meet again is the starting node of the cycle. Complexity: Time: O(n) Space: O(1) Concepts Practiced: Linked List traversal Floyd’s cycle detection Pointer manipulation #100DaysOfCode #LeetCode #DSA #Java #LinkedList #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 13/100 – LeetCode Challenge Problem: Linked List Cycle Today’s problem was about detecting whether a cycle exists in a linked list. Approach: Used Floyd’s Cycle Detection Algorithm (Tortoise and Hare). slow pointer moves one step fast pointer moves two steps If a cycle exists, both pointers will eventually meet If fast reaches null, the list has no cycle Complexity: Time: O(n) Space: O(1) Concepts Practiced: Linked List traversal Two-pointer technique Cycle detection algorithm #100DaysOfCode #LeetCode #DSA #Java #LinkedList #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 35/100 | #100DaysOfDSA 🌳💻 Today’s problem: Same Tree The goal is to determine whether two binary trees are identical — meaning they have the same structure and the same node values. Approach: • Use recursion to traverse both trees simultaneously • If both nodes are null → they match • If one node is null and the other isn’t → trees are different • If node values differ → trees are different • Recursively check the left and right subtrees Both trees must match at every node for them to be considered the same. Time Complexity: O(n) Space Complexity: O(h) (recursion stack) Big takeaway: When comparing two trees, traverse them in parallel and validate structure and values at each step. Simple logic, but a great exercise for strengthening recursive tree thinking. One more tree pattern learned. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
Day 14 – Binary Tree Postorder Traversal 🚀 Continuing my DSA journey with Striver’s A2Z Sheet / LeetCode practice. Today’s problem focused on Postorder Traversal of a Binary Tree, which is commonly used in problems involving tree deletion, evaluation, and bottom-up processing. 💡 Approach Postorder traversal follows this order: 1️⃣ Traverse the left subtree 2️⃣ Traverse the right subtree 3️⃣ Visit the root node Time Complexity : O(N) Space Complexity : O(N) Github Code : https://lnkd.in/gWW7Tq73 #LeetCode #DSA #StriverA2Z #CodingJourney #Java #BinaryTree #TreeTraversal #ProblemSolving #CodingPractice #SoftwareEngineering #TechInterviewPrep #100DaysOfCode #DeveloperJourney
To view or add a comment, sign in
-
-
🚀 Day #83/100 – 𝐈𝐧𝐭𝐞𝐫𝐬𝐞𝐜𝐭𝐢𝐨𝐧 𝐨𝐟 𝐓𝐰𝐨 𝐀𝐫𝐫𝐚𝐲𝐬 Today’s problem was Intersection of Two Arrays — a simple and clean problem focused on sets and uniqueness. 🔍 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠: Using a HashSet makes it easy to handle duplicates and find common elements efficiently. 💡 𝐂𝐨𝐫𝐞 𝐈𝐝𝐞𝐚: Store elements of the first array in a set Traverse the second array and check if elements exist in the set Use another set to store unique intersection results 𝐖𝐡𝐲 𝐢𝐭 𝐰𝐨𝐫𝐤𝐬? Sets automatically handle duplicates and provide O(1) lookup time, making the solution efficient. ⚡ 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Add all elements of nums1 into a set Traverse nums2: If element exists → add to result set Convert result set to array ⏱️ 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: O(n + m) 📦 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: O(n) #Day83 #100DaysOfCode #Java #DSA #LeetCode #HashSet #CodingJourney
To view or add a comment, sign in
-
-
Day 13 – Binary Tree Inorder Traversal 🚀 Continuing my DSA journey with Striver’s A2Z Sheet / LeetCode practice. Today’s problem focused on Binary Tree Inorder Traversal, one of the most fundamental traversal techniques used in many tree problems. In Inorder Traversal, we process nodes in the following order: 1️⃣ Traverse the left subtree 2️⃣ Visit the root node 3️⃣ Traverse the right subtree Time Complexity : O(N) Space Complexity : O(N) Github Code :- https://lnkd.in/gBv4uY4s #LeetCode #DSA #StriverA2Z #CodingJourney #Java #BinaryTree #TreeTraversal #ProblemSolving #CodingPractice #SoftwareEngineering #TechInterviewPrep #Day-13 #DeveloperJourney
To view or add a comment, sign in
-
-
Day 12 – Binary Tree Preorder Traversal 🚀 Continuing my DSA journey with Striver’s A2Z Sheet / LeetCode practice. Today’s problem was about tree traversal, specifically Preorder Traversal, which is one of the most fundamental concepts in Binary Trees. Approach :- Preorder traversal follows: 1️⃣ Visit the root node 2️⃣ Traverse the left subtree 3️⃣ Traverse the right subtree Time Complexity : O(N) Space Complexity : O(N) GitHub Code :- https://lnkd.in/e7skAAvF #LeetCode #DSA #StriverA2Z #CodingJourney #Java #BinaryTree #TreeTraversal #ProblemSolving #CodingPractice #SoftwareEngineering #TechInterviewPrep #Day12#DeveloperJourney
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