🚀 [Day 18/30] Coding Challenge with @Educative.io 💻 💡 Problem: Invert Binary Tree Today’s challenge was a classic tree problem — inverting a binary tree by swapping the left and right children of every node. The logic was simple yet powerful: 👉 Traverse the tree and swap left ↔ right at each node. I approached it using recursion: 1️⃣ Swap the left and right child 2️⃣ Recursively apply the same logic to both subtrees This can also be solved iteratively using BFS or DFS, but recursion keeps the solution very clean and readable. ✨ Small win: Problems like this remind me how elegant tree recursion can be — minimal code, clear intent. 🔍 Key Learnings: Tree transformations are often recursive by nature Preorder traversal works well for structural changes Simple problems still reinforce core fundamentals #30DaysOfCode #Day18 #CodingChallenge #Educative #DSA #BinaryTree #Recursion #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
Inverting Binary Tree with Recursion
More Relevant Posts
-
Why do so many programmers struggle with variables? Because they don’t understand what a variable really is—a simple box in memory with a label and a value. I’ve never seen it explained quite like this, but visualize a variable as a container somewhere in your computer that holds information. This insight alone changed the way I code and think about programming. In my latest video, I break down the principles of variables—mutability, types, assignment, and why understanding these fundamentals across languages like Swift, JavaScript, Python, C++, and Rust can make you a more versatile and adaptable programmer. Here’s something to test right now: next time you write a variable, pause and ask yourself—what kind of box am I creating? Is it mutable or immutable? What type of value fits inside this box? Understanding these answers before you write code will make your programming clearer and less error-prone. Programming languages are just different dialects for speaking the same underlying ideas. When you grasp these principles, translating between languages isn’t just easier—it’s effortless. How do you visualize variables and types when you’re coding? Does picturing variables as boxes with filters help you understand your programs better, or do you have a different mental model? I’m curious to hear how others conceptualize these basics that are often overlooked but crucial. https://lnkd.in/gvJKm_fb
Mastering the Core Principles of Every Coding Language!
https://www.youtube.com/
To view or add a comment, sign in
-
Day 16 | LeetCode Learning Journal 🚀 Today I tackled Problem 344: Reverse String. While it's a fundamental problem, it’s the perfect playground for mastering the Two-Pointer technique. It’s fascinating how shifting from a "create a new copy" mindset to an in-place manipulation approach can drastically optimize space complexity. Efficiency isn't just about speed; it's about being smart with the resources you have. Key Takeaways: In-place algorithms: Swapping elements directly within the array to achieve O(1) extra space. Efficiency: Seeing that "Accepted" screen with optimized memory usage is always a win. Refinement: Even simple problems offer a chance to write cleaner, more idiomatic C++ code. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #CPlusPlus #DSA #LearningInPublic #KeepGrowing #TwoPointers
To view or add a comment, sign in
-
-
Day 4/30 – Namaste DSA in JavaScript 🚀 Here’s what I covered: Second Largest Element in an Array - Continuing my DSA Learning Journey by writing logic to find the second largest element in a list/array. - This problem helped strengthen my understanding of comparisons, iterations, and tracking values while looping through arrays. - Learned how careful condition checks and efficient traversal can solve problems without unnecessary complexity. #30DaysOfCode #LearningJourney #DSA #ProgrammingBasics #Upskilling #NamasteDev #FrontendDevelopment #CodingJourney #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
Day 21 of 30-day Coding Sprint Today I solved Binary Subarrays With Sum, using one of the most clever mathematical tricks in the Sliding Window handbook. 930. Binary Subarrays With Sum - The Problem: Find the number of non-empty subarrays with a sum equal to a specific goal. - The Challenge: In a binary array (containing 0s and 1s), multiple windows can satisfy the same sum because zeros don't increase the sum but do create new subarrays. This makes a direct "exactly K" sliding window difficult to implement. - The Strategy: The Difference of "At Most" Instead of calculating "exactly goal" directly, I created a helper function to find subarrays with a sum at most goal. The Formula: Exactly(K) = AtMost(K) - AtMost(K-1) By subtracting the count of subarrays that sum to K-1 from those that sum to K, we are left with exactly the ones that equal K. Result: O(N) time complexity and O(1) space. Note: This "At Most" pattern is a life-saver for subarray problems involving counts. It simplifies the logic significantly—instead of managing complex pointers for a fixed sum, you're just measuring how many windows fit within a limit. #30DaysOfCode #DSASprint #LeetCode #JavaScript #SlidingWindow #BinaryArrays #Algorithms #Consistency
To view or add a comment, sign in
-
-
🚀 Day 21/30 – Coding Challenge 📌 Problem: Valid Perfect Square (LeetCode – 367) Given a positive integer, determine whether it is a perfect square without using any built-in functions like sqrt(). 🧠 Approach Used: Applied Newton’s Method (Binary-like approximation) Start with the number itself Repeatedly update the value using: x = (x + num / x) / 2 Stop when x * x ≤ num Finally, check if x * x == num ⚙️ Why this works: Efficient and avoids built-in math functions Handles large numbers safely using long Time Complexity: O(log n) ✅ Result: Solution accepted with 0 ms runtime 🎯 📈 One step closer every day — consistency over perfection! #Day21 #30DaysCodingChallenge #Java #LeetCode #DSA #ProblemSolving #NewtonMethod #CodingJourney
To view or add a comment, sign in
-
-
Most beginners rush to medium and hard problems in DSA. But the real question is — Are your fundamentals actually strong? I just published a new video on my YouTube channel JDCodebase where I solve two simple array problems: • Concatenation of Array • Running Sum of 1D Array These are easy-level problems, but they help you understand: - Array traversal clearly - In-place modification - Time and Space Complexity analysis - How to think step by step Sometimes growth in DSA is not about solving harder problems. It’s about solving simple problems correctly and confidently. If you’re starting your DSA journey, this will help you build a strong base. 🔗 Link in comments. #DSA #LeetCode #Programming #JavaScript #CodingForBeginners #DataStructures #Algorithms #LearningInPublic #JDCodebase
To view or add a comment, sign in
-
High-level languages help you build fast, but low-level programming teaches you how things break. When you understand memory, pointers, and the stack, you stop believing in "magic" and start seeing the logic. This knowledge transforms debugging from blind guesswork into precision engineering. You don't need to write C daily, but thinking in it makes you a better problem solver in any language. To build higher, you have to dig deeper. 🚀 #SoftwareEngineering #ComputerScience #LowLevelProgramming #CodingSkills #ProblemSolving
To view or add a comment, sign in
-
🔸 I recently started doing LeetCode again and have solved around 400 problems using JavaScript, across topics like dynamic programming, greedy, trees, graphs, recursion, arrays, and more I have done DSA before, but this time, something clicked. I realised that problem-solving becomes much easier once you start recognising the underlying patterns. The questions may still be difficult to code, but you’re no longer confused about what the problem actually wants from you. And that clarity changes everything. Instead of feeling stuck or overwhelmed, your mind starts breaking problems down naturally. You focus on constraints, edge cases, and trade-offs rather than panicking over the solution. That’s when you understand that real growth doesn’t come from memorising answers. It comes from training your brain to think in patterns Stay consistent Trust the process The “click” will come Pic Credit: AlgoMaster.io page #dsa #leetcode #javsacript #programming #technology #softwaredevelopment #competitiveprogramming #ig
To view or add a comment, sign in
-
-
New Feature Update We’re excited to introduce a new dropdown feature on SikshaSarovar, designed to enhance your learning and coding experience. What’s New? AI-Powered Online Results Instantly find results using AI in online mode for faster and smarter learning. Multi-Language Online Compiler Support Our compiler now supports 5 programming languages: Python C C++ Java JavaScript HTML This update combines AI assistance with hands-on coding practice, making SikshaSarovar a more powerful and interactive learning platform. Built for students, educators, and developers to learn, practice, and innovate—anytime, anywhere.
Assistant Professor | Founder@Sikshasarovar | Developer | TypeScript | React | Vite | Supabase | Node.js | PostgreSQL | Tailwind CSS | PWA | AI Integration
ANNOUNCEMENT | New Feature Update – SikshaSarovar We are excited to introduce a new dropdown feature on SikshaSarovar 🚀 What’s New? Wanna Try Visit Now :- https://lnkd.in/gt4TjNUB Learners can now find results using AI in online mode, making learning faster and more interactive. Our online compiler now supports 5 programming languages: ✅ Python ✅ C ✅ C++ ✅ Java ✅ JavaScript ✅ HTML This update enhances the hands-on learning experience by combining AI-powered assistance with multi-language coding support—all in one platform. Designed for students, educators, and aspiring developers to practice, learn, and get instant insights. #SikshaSarovar #NewFeature #AIinEducation #OnlineCompiler #ProgrammingLanguages #EdTech #LearningInnovation
To view or add a comment, sign in
-
🚀 Day 21 of 100 Days Of Coding #DrGViswanathan Challenge! Today was all about diving deep into C++ STL (Standard Template Library) and understanding how powerful and efficient it can be when used correctly. I explored multiple STL containers like vector, list, deque, stack, and pair, focusing on their commonly used member functions and iterative approaches. ✦ What I covered today: ▪ Element access methods like at(), [], front(), and back() ▪ Capacity and utility functions such as size(), empty(), and clear() ▪ Modifiers including push_back(), push_front(), pop_back(), pop_front(), insert(), and erase() ▪ Iteration using: ▫ Forward iterators with begin() and end() ▫ Reverse iterators with rbegin() and rend() to traverse containers from last to first ▫ Range-based for loops for cleaner and more readable code ▪ Working with pairs and understanding how data can be grouped efficiently Stack operations like push(), pop(), top(), and swap() ✦ Key learning highlight: One important concept I learned was the difference between push_back() and emplace_back(). ▪ push_back() inserts a copy or move of an existing object. ▪ emplace_back() constructs the object directly in place, which can improve performance by avoiding unnecessary copies. ▪ I also learned how swap() works across different STL containers, making it easy to exchange data efficiently. Overall, this session helped me build a stronger foundation in STL usage and iteration patterns, which are crucial for writing clean, optimized, and maintainable C++ code. On to Day 22 #STL #Challenge #Coding #LearningInPublic #DSA #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