Day 87 of #100DaysOfCode Today I solved "Convert Sorted List to Binary Search Tree" on LeetCode using Two Pointers + Recursion. Key Idea: A sorted linked list can be converted into a height-balanced BST by always choosing the middle element as root. Approach: • Use slow & fast pointers to find the middle node • Middle node becomes the root • Left part → build left subtree • Right part → build right subtree Repeat this process recursively to construct the entire BST. Concepts Used: • Linked List • Binary Search Tree (BST) • Two Pointers (Slow & Fast) • Recursion Time Complexity: O(n log n) Space Complexity: O(log n) This problem helped me understand how to transform one data structure into another efficiently From lists → to trees… leveling up data structure mastery #Day87 #100DaysOfCode #LeetCode #BST #LinkedList #Recursion #Cpp #CodingJourney
Converting Sorted List to Balanced BST with Two Pointers and Recursion
More Relevant Posts
-
🚀 Day 34/50 – #LeetCode Challenge Today’s problem: Product Price at a Given Date 📊 This one really tested my understanding of handling time-based data in SQL. 💡 Key Learning: When dealing with historical data, it's important to focus on the latest valid record before a given date — not just any record. 🔍 Approach I used: Consider all products Find the most recent price change on or before the target date (2019-08-16) If no change exists → use default price = 10 Used concepts like MAX(date), GROUP BY, and JOIN 🧠 What I improved today: Writing cleaner SQL queries Handling edge cases (no previous data) Thinking in terms of real-world data scenarios 🔥 Consistency is building confidence step by step. #Day34 #LeetCode #SQL #DataStructures #CodingJourney #Consistency #PlacementPreparation
To view or add a comment, sign in
-
-
Day 8/50 – #SQLChallenge 🚀 Solved “Customer Who Visited but Did Not Make Any Transactions” problem on LeetCode. ✅ Approach: Used LEFT JOIN with NULL filtering ✅ Key Concept: Identifying unmatched records between tables 💡 Advanced Insight: Filtering with IS NULL after a LEFT JOIN is a common pattern to find missing relationships (anti-join behavior). This is widely used in real-world scenarios like identifying inactive users, failed transactions, or missing data entries. 🔍 Takeaway: Understanding how to detect absence of data is just as important as retrieving existing data — especially in analytics and backend systems. Consistency is turning into confidence 💪 #SQL #LeetCode #Database #Joins #CodingChallenge #ProblemSolving #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
🚀 Day 28/50 #LeetCodeChallenge Today’s problem: Biggest Single Number This problem was a brilliant exercise in combining Aggregation with Subqueries to filter out duplicates effectively. 🔥 💡 Problem Insight: The task was to find the largest number that appears only once in the table. If no unique number exists, the result should be null. 🧠 Key Learning: Identify Uniqueness: Used GROUP BY combined with HAVING COUNT(*) = 1 to isolate numbers that don't repeat. The Power of MAX(): Applied MAX() on the filtered subset to grab the highest value. Handling Nulls: Using MAX() on a subquery is a clean way to ensure a null output if the criteria aren't met, instead of getting an empty result set. ⚡ Big Realization: The real trick isn't just finding the maximum—it's knowing how to exclude data that doesn't fit your constraints (duplicates) before you look for the top value. 📈 Takeaway: SQL logic is often about "layers." Filtering the noise first makes finding the answer straightforward. Consistency > Difficulty 💯 #Day28 #LeetCode #SQL #DataAnalytics #LearningJourney #CodingChallenge #50DaysOfChallenge
To view or add a comment, sign in
-
-
Day 18/100 of #100DaysOfCode 💻 Short query. Clear logic. Clean result. 🎯 Customer Placing the Largest Number of Orders:- Find the customer who placed the most orders from the Orders table. GROUP BY to count orders per customer → ORDER BY COUNT DESC to rank them → LIMIT 1 to grab the top one. Done. ✅ 💡 The real insight here - LIMIT 1 is one of those small but powerful tools. Instead of writing a subquery or CTE to find the max, just sort and slice. Cleaner and faster. Sometimes the best query is the shortest one. 🧩 Not every day is a Hard problem grind, some days you just stay consistent, show up, and keep the streak alive. That matters too. 😄 #SQL #100DaysOfCode #LearningInPublic #DataAnalytics #Consistency #DevJourney #LeetCode
To view or add a comment, sign in
-
-
39 problems solved. No shortcuts, no cramming. Just one problem a day — sometimes two if the first one clicks fast. Linked lists, backtracking, SQL queries, greedy scans. Each one a little uncomfortable at first, then suddenly obvious once it lands. That's kind of the whole point. Dashboard → https://lnkd.in/eWjTD6_P Repo → https://lnkd.in/ePM5inyX #LeetCode #CodingJourney #100DaysOfCode #BuildInPublic #SoftwareEngineering #ConsistencyOverMotivation #ProblemSolving
To view or add a comment, sign in
-
-
❄️ LeetCode Daily Challenge 📅 Day 34 of 50 Days SQL Challenge Today’s challenge was all about analyzing performance improvement over time — a very practical scenario in real-world analytics. 📌 Problem: Find Drivers with Improved Fuel Efficiency 🔗Problem Link: https://lnkd.in/gWqPXFQN 💡 Problem Breakdown: Identify drivers whose fuel efficiency improved: ✔ Calculate efficiency per trip (distance / fuel) ✔ Compare average efficiency between first half (Jan–Jun) and second half (Jul–Dec) ✔ Include only drivers with trips in both halves ✔ Compute improvement = second_half_avg - first_half_avg 34 days of consistent SQL practice completed ✅ Daily practice is turning concepts into intuition 💪 Let’s grow one query at a time 🚀 Drop your approach below 👇 #LeetCode #SQL #DataEngineering #Analytics #PerformanceAnalysis #SQLPractice #LearningInPublic #50DaysChallenge #DataAnalytics
To view or add a comment, sign in
-
-
Day 9/50 – #SQLChallenge 🚀 Solved “Rising Temperature” problem on LeetCode. ✅ Approach: Used SELF JOIN to compare rows within the same table ✅ Key Concept: Comparing consecutive records using date difference 💡 Advanced Insight: Since SQL doesn’t have a direct way to access the previous row, a SELF JOIN helps simulate this behavior by pairing each record with its previous day. This pattern is widely used in time-series data analysis. 🔍 Takeaway: Understanding how to compare rows across time is crucial for real-world scenarios like tracking growth, trends, and performance metrics. Consistency is compounding 📈 #SQL #LeetCode #Database #Joins #CodingChallenge #ProblemSolving #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
🚀 Day 41/50 #LeetCodeChallenge Today’s Problem: Friend Requests II: Who Has the Most Friends 💡 Key Learnings: Strengthened understanding of UNION ALL to combine datasets Practiced GROUP BY + COUNT for aggregation Learned how to handle undirected relationships (counting both requester & accepter) Connected SQL logic with real-world graph concepts (user connections) 🧠 Approach: Combined requester_id and accepter_id into a single dataset, then calculated total friends for each user and identified the one with the highest connections. 🔥 Insight: This problem is similar to finding the degree of a node in a graph, commonly used in social network analysis. #SQL #LeetCode #ProblemSolving #LearningInPublic #50DaysOfCode
To view or add a comment, sign in
-
-
Day 21/100 of #100DaysOfCode 💻 Today's problem made me think in trees. 🌳 Tree Node:- Given a tree structure in a table, classify each node as Root, Inner, or Leaf. The logic: Root → has no parent (p_id IS NULL) Inner → appears as a parent of someone else Leaf → everything else I didn't get it right on the first try. 😅 My first attempt used "WHERE p_id = 1" inside the subquery, which hardcodes the root and breaks for any other tree structure. Wrong logic, wrong output. Then I stepped back and thought about it properly (Code is given in the image) 💡 The fix is instead of hardcoding, ask "does this node appear as a parent of anyone?" If yes → Inner. That's the real tree logic. Never hardcode what SQL can figure out dynamically. 🧩 Trial and error is part of the process. The wrong attempt taught me more than the right one. 😄 #SQL #100DaysOfCode #LearningInPublic #DataAnalytics #Consistency #DevJourney #LeetCode
To view or add a comment, sign in
-
-
When declaring variables, it's tempting to hardcode the data types (for example: v_name VARCHAR2(50)). But what happens if the database column size is changed to 100 later on? Your code will crash when trying to fetch larger data! The pro-habit for beginners? Use %TYPE and %ROWTYPE! Instead of hardcoding, you can "anchor" your variables directly to the table's columns: _ v_name employees.first_name%TYPE; Now, if the database table structure changes in the future, your variables adapt automatically. _No need to go back, hunt down errors, and rewrite your code! It’s a simple trick that saves hours of debugging and makes your code much easier to maintain. #PLSQL #OracleDatabase #CodingTips #CleanCode
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