Two Farthest Houses with Different Colors LeetCode Breakthrough

🚨 I didn’t check every pair… and still got the maximum distance. Day 29 of my Backend Developer Journey — and today was about 👉 thinking smart instead of thinking more 🧠 LeetCode Breakthrough Solved “Two Farthest Houses with Different Colors” 💡 What clicked: → No need to compare all pairs → Just compare with first and last house → Expand from both ends ⚡ The real trick: 👉 The farthest distance will always involve either the first or the last element 🔍 Key Insight Instead of brute force (O(n²)): 👉 Use two pointers 👉 Compare edges only ⚡ Optimized to O(n) with simple logic 🔗 My Submission:https://lnkd.in/gE4cBmuV ☕ Spring Boot Learning 🔁 JPA Repository Revision Today I revisited the core of Spring Data JPA 👇 👉 JpaRepository simplifies database operations 👉 No need to write boilerplate SQL 👉 Built-in methods like: → save() → findById() → findAll() → delete() ⚡ Why this matters 💡 Strong fundamentals > New concepts 👉 Writing less code 👉 Getting more done 👉 Cleaner backend design 🧠 The Shift 👉 Optimization is about observing patterns 👉 Revising basics makes concepts stronger 👉 Backend mastery = consistency + clarity 📘 Spring Boot Notes:https://lnkd.in/gpWQvkyK 📈 Day 29 Progress: ✅ Improved problem-solving efficiency ✅ Strengthened JPA fundamentals ✅ Practicing consistency daily 💬 Have you ever solved a problem faster by doing less work? 😄 #100DaysOfCode #BackendDevelopment #SpringBoot #Java #LeetCode #CodingJourney

  • text

To view or add a comment, sign in

Explore content categories