Just solved “Search in a Binary Search Tree” in Java with 100% runtime efficiency This problem was a great reminder of how elegant and efficient Binary Search Tree (BST) traversal can be when approached iteratively. 🔍 Key Idea: Start from the root and navigate left or right based on the target value — no recursion, just clean and optimized logic! 💡 Takeaway: Sometimes the simplest, most readable solutions are also the fastest. Writing clean and efficient code is a skill built through consistency and understanding the fundamentals. #Java #LeetCode #DSA #BinarySearchTree #CodingJourney #ProblemSolving #CleanCode
Solved "Search in a Binary Search Tree" in Java with 100% efficiency
More Relevant Posts
-
🚀 Day 20 of #100DaysOfLeetCode 💡 Problem: Gray Code Today’s challenge was all about generating the Gray Code sequence, a fascinating binary numbering system where only one bit changes between consecutive numbers. 🧠 Concept: Gray codes are widely used in digital communication and error correction, ensuring minimal transition errors between binary states. 🔍 Key takeaway: Bit manipulation + recursion = elegant solution ✨ 💻 Languages used: Java #LeetCode #100DaysOfCode #ProblemSolving #CodingChallenge #Java #GrayCode #DSA #BitManipulation
To view or add a comment, sign in
-
-
🌳 Day 46 of #LeetCodeJourney Problem: 100. Same Tree ✅ Today’s challenge was about comparing two binary trees — checking if they’re structurally identical and have the same node values. A neat recursive problem that refreshes the basics of tree traversal and recursion! 💡 Key takeaway: If you can break a problem down into smaller identical subproblems — recursion will always have your back. #LeetCode #100DaysOfCode #Java #DSA #BinaryTree #Recursion #CodingJourney
To view or add a comment, sign in
-
-
🧠 Total Grid Ways Problem — Recursive Approach in Java 💻 Exploring how to find all possible paths from the top-left corner to the bottom-right corner in a grid — moving only right or down. This recursive solution breaks the problem into smaller subproblems, combining their results to find total unique paths. ✨ Sometimes, even a simple grid teaches us how powerful recursion can be!
To view or add a comment, sign in
-
-
Day 28/100 – #100DaysOfCode 🚀 | #Java #LeetCode #DynamicProgramming ✅ Problem Solved: Scramble String 🔀 🧩 Problem Summary: Given two strings s1 and s2, determine whether one is a scrambled version of the other. A string is scrambled by recursively dividing it into two non-empty substrings and swapping them. 💡 Approach Used: Implemented Recursion + Memoization using a HashMap for overlapping subproblems. Used character frequency checks to prune unnecessary recursion calls. Used Java’s BiFunction with inline helper logic for recursion. ⚙️ Time Complexity: O(n⁴) (due to substring operations and recursion) 📦 Space Complexity: O(n²) ✨ Takeaway: Even complex recursive problems can be optimized efficiently with Memoization and early pruning. 🚀 #Java #LeetCode #DynamicProgramming #Recursion #ProblemSolving #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
🎯 Day 62 of #100DaysOfLeetCode Today I solved the “Merge Two Sorted Lists” problem using Java This problem is a great exercise in understanding how to work with Linked Lists and pointer manipulation. The goal is to merge two sorted linked lists into one sorted list — without using extra space for another list. Key Concepts Practiced: Linked List traversal Dummy node technique Efficient merging using pointers Handling null edge cases Approach Summary: Create a dummy node to simplify edge cases. Use two pointers to traverse both lists. Compare values and link nodes in sorted order. Attach any remaining nodes at the end. #100DaysOfCode #LeetCode #Java #CodingChallenge #DataStructures #LinkedList #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Another late-night success Solved a tricky binary search + sliding window problem efficiently in Java, optimizing power distribution logic in minimal runtime. 📊 Runtime: 31 ms 💡 Beats 89.29% of Java submissions 🧩 Concepts used: Binary Search, Prefix Sum, Sliding Window Each accepted solution reminds me that writing clean, efficient code isn’t just about passing tests — it’s about thinking like the system itself. #Java #LeetCode #ProblemSolving #Algorithms #CodingJourney
To view or add a comment, sign in
-
-
𝐓𝐡𝐞 𝐉𝐚𝐯𝐚 𝐟𝐞𝐚𝐭𝐮𝐫𝐞 𝐧𝐨𝐛𝐨𝐝𝐲 𝐭𝐚𝐥𝐤𝐬 𝐚𝐛𝐨𝐮𝐭 — 𝐛𝐮𝐭 𝐞𝐯𝐞𝐫𝐲 𝐟𝐥𝐮𝐞𝐧𝐭 𝐀𝐏𝐈 𝐬𝐢𝐥𝐞𝐧𝐭𝐥𝐲 𝐝𝐞𝐩𝐞𝐧𝐝𝐬 𝐨𝐧. A few nights ago, while refactoring some old Java code, I noticed something that made me pause. A subclass method had the same name and parameters as its parent… but it returned a different type. And to my surprise — it compiled perfectly. That’s when I re-discovered one of Java’s most underrated features: 👉 Covariant Return Types In simple terms: When a subclass overrides a method, it can return a more specific type than the parent Before Java 5, this wasn’t possible. Now it’s what quietly powers builder patterns, method chaining, and fluent APIs. Because the compiler says: “𝐈𝐟 𝐲𝐨𝐮𝐫 𝐬𝐮𝐛𝐜𝐥𝐚𝐬𝐬 𝐩𝐫𝐨𝐦𝐢𝐬𝐞𝐬 𝐭𝐨 𝐫𝐞𝐭𝐮𝐫𝐧 𝐢𝐭𝐬𝐞𝐥𝐟, 𝐈’𝐥𝐥 𝐭𝐫𝐮𝐬𝐭 𝐲𝐨𝐮 — 𝐧𝐨 𝐫𝐮𝐧𝐭𝐢𝐦𝐞 𝐜𝐡𝐞𝐜𝐤 𝐧𝐞𝐞𝐝𝐞𝐝.” Next time you chain methods in Java, remember — it’s Covariant Return Types working behind the scenes 🧠 #Java #Coding #SoftwareEngineering #OOP #CleanCode #TechInsights
To view or add a comment, sign in
-
-
💡 Java Collections — Under the Hood Understanding how collections work = writing faster, efficient code. 🔹 HashMap → Key-value, hash buckets + tree structure (since Java 8) 🔹 HashSet → Built on HashMap 🔹 ArrayList → Dynamic resizing arrays 🔹 LinkedList → Doubly linked nodes 🔹 TreeMap → Red-black tree sorted by key Master these, and performance tuning becomes instinctive ⚙️ 💬 Which one do you use most often — and why? #Java #DataStructures #Coding #SystemDesign #BackendDevelopment
To view or add a comment, sign in
-
-
#Day-69) LeetCode 2536: Increment Submatrices by One using a 2D difference array technique in Java — a powerful approach for handling multiple range updates efficiently. 🔧 Instead of brute-force iteration over each query, I used a prefix sum strategy to apply all updates in constant time per query, followed by a cumulative pass to build the final matrix. 🧠 Highlights: Efficient submatrix updates using difference matrix Prefix sum accumulation for final values Clean, scalable Java implementation 📌 This kind of problem is a great reminder: smart preprocessing beats brute force. Let’s connect if you’ve explored similar matrix tricks or want to brainstorm more Java optimizations! #Java #LeetCode #DSA #MatrixOptimization #CodingInPublic #ProblemSolving #TechJourney #LinkedInTech
To view or add a comment, sign in
-
-
💻 Day 30 🚀of #30DaysOfLeetCode Problem: Move Zeroes https://lnkd.in/gBYJphPM Language: Java ☕ 🧠 Logic: Traverse the array, move all non-zero elements forward, and fill remaining positions with zeros — all done in-place! ✅ Result: Runtime: 2 ms (Beats 79.18%) Memory: 46.02 MB (Beats 80.31%) 🗣️ “Optimization isn’t about speed alone — it’s about clean, efficient logic.” #LeetCode #Java #CodingChallenge #30DaysOfCode #ProblemSolving #MoveZeroes #Day30 #CodeDaily
To view or add a comment, sign in
-
Explore related topics
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