🚀 From Overthinking to Clean Logic — SQL Growth Moment! Solved “Triangle Judgement” on LeetCode and this one taught me something important 💡 At first, I tried solving it using nested CASE statements and multiple conditions — it worked, but it was unnecessarily complex. Then I realized the problem boils down to a simple mathematical rule 👇 👉 A triangle is valid if: x + y > z x + z > y y + z > x 🧠 Final Clean Approach: SELECT x, y, z, CASE WHEN x + y > z AND x + z > y AND y + z > x THEN 'Yes' ELSE 'No' END AS triangle FROM Triangle; 📊 Result: ✔️ Accepted ✅ (11/11 test cases passed) ✔️ Runtime: 305 ms 🔥 Key Takeaway: Sometimes the best solution isn’t the most complex one — it’s the simplest correct logic. Learning to simplify is just as important as learning to solve 💪 #SQL #LeetCode #CodingJourney #ProblemSolving #Learning #Tech #PlacementPreparation
Simplifying SQL for LeetCode's Triangle Judgement
More Relevant Posts
-
#sqldiaries Writing multiple lines of code used to feel intimidating — like staring at a wall with no clear way over it. But something changed when I started breaking problems into smaller steps. Instead of trying to “solve everything at once,” I focused on understanding what’s actually happening in the problem. The clearer the problem became, the simpler the solution felt. LeetCode questions that once looked complex started turning into a series of logical decisions. Step by step. Piece by piece. And that’s when it clicked: Real-world data is messy, unpredictable, and rarely comes in a clean format. So the real skill isn’t just writing code — it’s thinking clearly, structuring chaos, and building solutions one logical block at a time. That’s how you go from feeling stuck… to actually solving problems.
To view or add a comment, sign in
-
-
Day 36/90 Why does "working" code often fail in production? Because edge cases like N+1 queries, duplicate data, and inaccurate stats don't show up when you're testing with just two users. Today I refactored the Course Module to fix these foundation issues and make sure the backend is actually ready for real-world use. Day 36 was spent fixing errors in the code and making database queries faster. Instead of adding new parts to the project, the focus was on making sure the existing code works correctly under different conditions. This meant looking at how the database handles information and closing gaps where incorrect data could get through. Backend: • Security Hardening: Replaced manual database lookups with self.get_object() to standardize permission and error handling. • Database Integrity: Implemented a conditional UniqueConstraint that allows re-enrollment while still preventing duplicate active records. • Performance Gains: Applied select_related and prefetch_related to kill N+1 queries in student and teacher listings. • SQL Annotations: Offloaded math for question counts and course statistics to the database using annotations. • Data Accuracy: Updated counting logic to exclude soft-deleted records, fixing inflated statistics on the dashboard. • API Reliability: Disabled page size overrides and used local paginator instances to keep API results consistent with documentation. • Data Migration: Created a RunPython migration script to convert legacy string statuses to new character codes without data loss. • Response Cleanup: Refactored the teacher endpoint to return direct resources and resolved field conflicts in nested serializers. At what stage of a project do you stop adding new features to focus entirely on refactoring and hardening the code? #Day90Challenge #Django #Python #Backend #BuildInPublic
To view or add a comment, sign in
-
-
Small wins don’t look small when you know the effort behind them. Just hit SQL 50 on LeetCode — not a huge milestone on paper, but it forced me to slow down, think clearly, and actually understand what I was writing instead of just “making queries work.” What changed for me wasn’t just solving problems — it was: • thinking in joins instead of steps • debugging logic instead of syntax • realizing how easy it is to get almost correct answers Still a long way to go, but this feels like a solid step in the right direction. On to the next 50.... #SQL #LeetCode #DataStructures #ProblemSolving #LearningJourney #Consistency #TechGrowth #SoftwareEngineering #CodingLife #DeveloperMindset #KeepBuilding #100DaysOfCode #DataAnalytics #BackendDevelopment #QueryOptimization #StudentsInTech #FutureEngineer #GrowthMindset #PracticeMakesProgress #TechCareers
To view or add a comment, sign in
-
-
Day 13: 90-Day Coding Challenge 🚀 Today I worked on a classic SQL problem — identifying users who logged in for N consecutive days. At first glance, this looks like a simple aggregation problem, but the real challenge is detecting continuous sequences of dates without gaps. 🔍 Approach I used: • Leveraged window functions like ROW_NUMBER() • Created a pattern by subtracting row number from login date to group consecutive days • Aggregated based on this derived key to identify continuous streaks • Filtered users whose streak length ≥ N 💡 Key Insight: Instead of checking each day individually, transforming dates into groups helps detect consecutive patterns efficiently. ⚡ This is a powerful technique often used in: • User retention analysis • Streak tracking (daily active users) • Behavioral analytics Time Complexity: O(n log n) (due to sorting/window functions) Today’s learning highlights: ✅ Mastered handling consecutive patterns in SQL ✅ Practiced window functions for real-world scenarios ✅ Improved thinking around sequence detection ✅ Strengthened SQL problem-solving skills These kinds of problems really show how SQL can go beyond simple queries into analytical problem solving 🔥 Excited for Day 14! #90DaysOfCode #SQL #WindowFunctions #DataEngineering #Analytics #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
🚀 Mastering Data Structures: Linked Lists Deep Dive 🚀 Let's unravel the mystery of Linked Lists! 🧵🔗 In simple terms, a linked list is a linear data structure where each element is a separate object called a node. These nodes are connected using pointers, forming a chain. But why should developers care? 🤔 Well, understanding linked lists is crucial for optimizing memory usage and efficiently managing data, especially when dealing with frequent insertions and deletions. It's a fundamental concept to grasp for mastering more complex data structures. Here's a breakdown to get you started: 1️⃣ Create a Node class with data and a reference to the next node. 2️⃣ Implement methods for inserting, deleting, and traversing nodes. ```python class Node: def __init__(self, data=None): self.data = data self.next = None # Placeholder for code implementation ``` Pro tip: Keep track of the head and tail nodes for faster operations! 🚴 Common mistake alert: Forgetting to update the pointers correctly when inserting or deleting nodes can lead to bugs. 🐞 Double-check your logic! What's your favorite use case for linked lists? Share below! 💬 🌐 View my full portfolio and more dev resources at tharindunipun.lk #DataStructures #LinkedLists #CodingBeginners #DeveloperTips #PythonProgramming #MemoryOptimization #CodeOptimization #CodingJourney #LearnToCode
To view or add a comment, sign in
-
-
🔥 Day 23/50 of #LeetCode Challenge Today’s learning was all about understanding uniqueness in data. 📌 Problem: Count how many unique subjects each teacher teaches. 💡 Key Insight: Even if a teacher teaches the same subject in multiple departments, it should be counted only once. 🧠 What I learned: Always focus on the actual requirement, not just the data rows Duplicate data can mislead your logic if not handled carefully Thinking in terms of real-world scenarios makes problems easier 🎯 One-line takeaway: 👉 Count subjects, not rows Consistency is the key — showing up every day 🚀 #SQL #LeetCode #DataAnalytics #100DaysOfCode #LearningJourney
To view or add a comment, sign in
-
-
Day 3. Finished File Handling — my code can now find files, read them, and not panic like me during exams. Started NumPy — found out loops are basically cancelled. You just suggest something to an array and it respectfully obeys. Then Pandas… Opened a dataset → looked fine Used .info() → trust issues started Used .isnull() → betrayal confirmed Missing values everywhere like they pay no rent. .fillna() and .dropna() = emotional damage control. Built a mini project: - Loaded data - Cleaned it - Did some NumPy math - Saved it to JSON (because that’s what professionals do) Conclusion: Coding is easy. Data just wakes up and chooses violence. Day 3 done.
To view or add a comment, sign in
-
Most beginners struggle with SQL not because it's hard… but because their queries are messy. That’s where CTEs (Common Table Expressions) change the game 👇 🔹 Break complex queries into simple steps 🔹 Improve readability (no more spaghetti SQL) 🔹 Make your logic modular & reusable 🔹 Easier debugging = faster learning 👉 Instead of writing one giant query, think like this: “Divide → Simplify → Combine” 📌 Key Types you should know: ✔️ Standalone CTE ✔️ Nested CTE ✔️ Multiple CTEs ✔️ Recursive CTE 💡 Real talk: If your SQL is hard to read, it’s not powerful — it’s weak. Clean SQL = Professional SQL. Start using CTEs today, and you’ll instantly level up your query game 🚀 #SQL #DataAnalytics #LearnSQL #DataScience #Coding #CTE #Tech #Programming #LinkedInLearning
To view or add a comment, sign in
-
-
Data with Consequences: Building an Automated Penalty System 🎓💸 Day 70/100 Data is just information until you use it to drive action. 🏗️ I’ve hit Day 70 of my #100DaysOfCode journey! After finishing the core SQL modules, I wanted to build something that mirrors real-world administrative systems. Today, I built an Automated Attendance & Fine System that bridges the gap between Database Queries and Business Logic. Technical Highlights: ⚙️ Schema Evolution: Using ALTER TABLE to dynamically add new attributes (Attendance %) to an existing database. 🎯 Conditional Triggers: Fetching specific records that fall below a threshold (75% attendance) to initiate processing. 🧮 Algorithmic Penalties: Using Python to calculate dynamic fines based on the 'gap' between current data and the required benchmark. 📊 Reporting: Generating a clean, actionable summary that turns raw database rows into a financial audit. The Engineering Mindset: Whether it’s a bank charging a late fee or a gym identifying expired memberships, the logic is the same: Query -> Analyze -> Act. Do check my GitHub repository here : https://lnkd.in/d9Yi9ZsC #SQL #Python #100DaysOfCode #BTech #IILM #ComputerScience #AIML #Automation #SoftwareEngineering #LearningInPublic #WomenInTech #DataEngineering
To view or add a comment, sign in
-
-
Day 2 of solving SQL problems on LeetCode 💻 Today I worked on problems involving: • SELF JOIN (comparing rows within the same table) • LEFT JOIN (finding missing records) • Filtering + grouping logic One key realization: SQL is not about syntax — it's about thinking in patterns. For example: When a question says “find missing” → think LEFT JOIN + NULL When it says “compare with previous row” → think SELF JOIN or LAG Every problem is training my brain to think more analytically. Consistency > Motivation 🚀 #SQL #MySQL #Database #DataScience #DataAnalytics #Analytics #LeetCode #ProblemSolving #Coding #Programming #Tech #100DaysOfCode #LearnInPublic #Developer #SoftwareEngineering #AI #MachineLearning #DataEngineer #CareerGrowth #Students
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