🚀 Day 35 of 100 Days of LeetCode 📘 Problem: Binary Tree Inorder Traversal 💻 Language: Java ✅ Status: Accepted — Runtime ⚡ 1 ms Today’s focus was on mastering tree traversal, one of the most essential techniques in data structures 🌳 The goal was simple — visit nodes in order (Left → Root → Right), but the recursive logic behind it reinforced clarity and structured thinking. ✨ Key Learnings: Recursive approach simplifies traversal logic 🧠 Base cases are the backbone of recursion Understanding tree patterns helps in mastering complex problems like BSTs and DFS 💬 “A binary tree teaches one thing — structure leads to clarity.” #Day35 #100DaysOfCode #LeetCode #Java #BinaryTree #Recursion #ProblemSolving #DSA #CodingJourney #SoftwareDevelopment #KeepLearning
Mastering Tree Traversal with Java on Day 35 of 100 Days of LeetCode
More Relevant Posts
-
🗓 Day 8 / 100 – #100DaysOfLeetCode 📌 Problem 474: Ones and Zeroes The task was to determine the largest subset of binary strings that can be formed using at most m zeros and n ones — essentially a two-dimensional 0/1 Knapsack problem. 🧠 My Approach (in Java): Counted the number of zeros and ones in each string. Used a 2D DP array dp[m][n] to store the maximum subset size possible with given zeros and ones. Iterated in reverse order to ensure each string is only used once (knapsack-style update). Updated states using dp[i][j] = max(dp[i][j], dp[i - zeros][j - ones] + 1). ⏱ Time Complexity: O(len(S) × M × N) 💾 Space Complexity: O(M × N) 💡 Key Learning: This problem strengthened my understanding of multi-dimensional DP — especially how to translate real-world constraints into DP states. It’s a great reminder that mastering DP isn’t about memorizing patterns but about building intuition on state transitions and decisions. Consistent effort. Deep learning. Step by step 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Java #DynamicProgramming #Knapsack #Algorithms #ProblemSolving #DataStructures #DSA #CodingJourney #CompetitiveProgramming #SoftwareEngineering #LearningInPublic #DeveloperJourney #TechStudent #LogicBuilding #CodingCommunity #CodeEveryday #CareerGrowth #Optimization #KeepLearning
To view or add a comment, sign in
-
-
#Day_28 Today’s problem was quite an interesting one — “Reach a Target Number” using minimal moves. 💡 Problem Summary: Starting from 0, on each move i, you can go either left or right by i steps. The goal is to find the minimum number of moves required to reach a given target. At first glance, it looked like a simple math problem, but the trick was to notice the parity condition — once the cumulative sum goes beyond the target, the difference (sum - target) must be even to allow flipping directions and still land exactly on target. Here’s the optimized logic I implemented in Java Key Takeaway: Sometimes, problems that look complex are just about observing patterns in numbers rather than brute force. A touch of math can simplify the entire logic! #100DaysOfCode #LeetCode #CodingChallenge #Java #ProblemSolving #DSA #LearnEveryday #CodingJourney
To view or add a comment, sign in
-
-
Day 80 of #100DaysOfCode Solved Frequency Sort in Java 🔠 Approach Today's problem was to sort an array based on the frequency of its numbers. My initial solution was accepted, but it exposed a major efficiency gap! My strategy involved: Sorting the array first. Using nested loops to count the frequency of each number and store it in a HashMap. (Implied) Using the counts to perform the final custom sort. The core issue was the counting method: running a full loop inside another full loop to get the frequency. This quadratic $O(N^2)$ counting completely tanked the performance. ✅ Runtime: 29 ms (Beats 12.02%) ✅ Memory: 45.26 MB (Beats 5.86%) Another great lesson in algorithmic complexity! The difference between $O(N^2)$ and the optimal $O(N \log N)$ for this problem is massive. Time to refactor and implement the fast, single-pass $O(N)$ frequency count using getOrDefault! 💪 #Java #100DaysOfCode #LeetCode #CodingChallenge #Algorithms #Arrays #HashMap #Optimization #ProblemSolving
To view or add a comment, sign in
-
-
💻 Day 53 of #100DaysOfCode 💻 Today, I solved LeetCode Problem #709 – To Lower Case 🔠 This problem focuses on string manipulation and character encoding (ASCII values) — one of the simplest yet fundamental concepts in text processing. 💡 Key Learnings: Reinforced understanding of ASCII value ranges for uppercase and lowercase alphabets. Practiced efficient string traversal and conditional conversion using StringBuilder in Java. Time complexity: O(n) — iterates through the string once. Space complexity: O(n) — for the output string. 💻 Language: Java ⚡ Runtime: 0 ms — Beats 100% 🚀 📉 Memory: 41.78 MB — Beats 43.48% 🧠 Approach: 1️⃣ Iterate through each character in the string. 2️⃣ Check if it’s an uppercase letter (A–Z). 3️⃣ Convert it to lowercase by adding 32 (based on ASCII values). 4️⃣ Append to the final string using StringBuilder. ✨ Takeaway: Sometimes, understanding the basics like ASCII values can help you write your own efficient methods — without relying on built-in functions! #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #Algorithms #StringManipulation #SoftwareEngineering #LearningEveryday #CleanCode
To view or add a comment, sign in
-
-
📌 Day 14/100 - Group Anagrams (LeetCode 49) 🔹 Problem: Given an array of strings, group the anagrams together. An anagram is a word formed by rearranging the letters of another — like “eat”, “tea”, and “ate”. 🔹 Approach: Traverse through each word in the array. Sort its characters alphabetically to form a key. Use a HashMap to group words with the same key. Return all grouped lists as the final result. 🔹 Key Learning: ✅ Sorting helps identify similar string patterns. ✅ HashMaps make grouping efficient and clean. ✅ Small logical steps lead to elegant solutions. Consistent effort turns complexity into clarity 💪 #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingJourney #LearningEveryday
To view or add a comment, sign in
-
-
✅ #PostLog28 Search in Rotated Sorted Array (Problem #33) Problem tested my understanding of binary search in modified arrays — where the array is rotated at an unknown pivot. 🧠 Concept learned: Even though the array is rotated, one half of it is always sorted. By identifying which half is sorted, we can efficiently narrow down our search range — still achieving O(log n) complexity! ⚙️ Approach Summary: Use binary search. Check if the left or right half is sorted. Move search boundaries accordingly based on the target’s range. 💻 Language: Java 📈 Result: Accepted ✅ — 0 ms runtime (beats 100%) #LeetCode #Java #CodingChallenge #DSA #BinarySearch
To view or add a comment, sign in
-
-
Day 37/100 ✅ Binary Tree Postorder Traversal Today I solved the Binary Tree Postorder Traversal problem using a simple recursive approach in Java. In postorder traversal, we visit nodes in the order Left → Right → Root. This helps in many real-world tree-based algorithms like expression tree evaluations or file system traversal. 💡 Approach: I used recursion — first visiting the left child, then the right child, and finally adding the node’s value to the result list. It’s clean, elegant, and easy to understand! ✅ Key Learning: Understanding traversal patterns (Preorder, Inorder, Postorder) is essential for mastering tree-based problems. Each pattern teaches how to process data at different stages of recursion. #LeetCode #Java #CodingJourney #DSA #BinaryTree #Recursion #PostorderTraversal #100DaysOfCode
To view or add a comment, sign in
-
-
𝗕𝗲𝗵𝗶𝗻𝗱 𝘁𝗵𝗲 𝗦𝗰𝗲𝗻𝗲𝘀 𝗼𝗳 𝗝𝗮𝘃𝗮 𝗔𝗿𝗿𝗮𝘆𝗟𝗶𝘀𝘁! Today, I implemented a 𝗗𝘆𝗻𝗮𝗺𝗶𝗰 𝗔𝗿𝗿𝗮𝘆 in Java — building the logic from scratch to understand how ArrayList actually works under the hood. ⚙️ This exercise gave me hands-on exposure to how resizing, shifting, and accessing elements are efficiently handled in dynamic data structures. 𝗛𝗲𝗿𝗲’𝘀 𝘄𝗵𝗮𝘁 𝗜 𝗶𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗲𝗱 👇 🔹 add(element) — to append new items dynamically 🔹 add(index, element) — to insert at a specific position 🔹 get(index) — to fetch values efficiently 🔹 set(index, element) — to replace existing elements 🔹 remove(index/element) — to delete items and shift elements 🔹 contains(element) — to check for existence 🔹 isEmpty() & clear() — to manage and reset the structure 𝗜𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝗱𝗲 : https://lnkd.in/gXEfwXvf 📘 𝗞𝗲𝘆 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: Recreating ArrayList from scratch deepened my understanding of how memory reallocation, indexing, and dynamic resizing make it one of the most powerful data structures in Java’s Collection Framework. Learning the “how” behind the “what” truly builds stronger foundations. 💪 #Java #DataStructures #ArrayList #CodingJourney #LearningByDoing #SoftwareEngineering #DSA #100DaysOfCode
To view or add a comment, sign in
-
-
Day 38 of #100daysOfCode Problem: 3542. Minimum Operations to Convert All Elements to Zero Difficulty: Medium Language: Java Status: Solved Problem Summary: You are given an integer array nums. In one operation, you can select a subarray [i, j] and set all occurrences of the minimum non-zero integer in that subarray to 0. Your goal is to make all elements zero in the minimum number of operations. Key Insight: This problem can be reduced to tracking how many times the current subarray’s minimum changes. A monotonic stack efficiently tracks the increasing sequence of elements. Each time a smaller element is encountered, it indicates that a set of operations can be completed (popped from stack). What I Learned: Monotonic stacks aren’t just for “next greater” or “next smaller” problems—they can also represent layers of operations or intervals. Elegant one-pass logic using stack simulation can drastically simplify range operation problems. #Day38 #100DaysOfCode #LeetCode #DSA #MonotonicStack #Java #Algorithms #ProblemSolving #CodingChallenge #SoftwareEngineering #LearnByCoding
To view or add a comment, sign in
-
-
#Day44 of Problem Solving Solved “Concatenation of Array” on LeetCode with an optimized Java solution — achieving 1 ms runtime, which beats 96.77% of submissions! ⚡ Key Learnings: Strengthened understanding of array manipulation and memory allocation in Java. Reinforced the importance of clean and efficient code in problem-solving. Practiced writing scalable logic with minimal complexity. Every small step counts toward mastering data structures and algorithms. 🚀 #LeetCode #CodingJourney #JavaProgramming #ProblemSolving #DataStructures #Algorithms #100DaysOfCode #KeepLearning #Consistency #DSA #Linkedin #HackerRank
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