Solved LeetCode 3761 with HashMap and Hibernate Entity Lifecycle

🚨 I solved this problem… but the real learning was in how I stored data. Day 26 of my Backend Developer Journey — and today was all about thinking ahead while iterating 👇 🧠 LeetCode Breakthrough Solved LeetCode 3761. Minimum Absolute Distance Between Mirror Pairs 💡 What clicked: → Reverse the number to find its mirror → Store reversed values in HashMap → Check distance while iterating ⚡ The key trick: Instead of searching later… 👉 Prepare data in advance while traversing 🔍 Key Insight 👉 Store future-use data (reversed numbers) 👉 Avoid nested loops 👉 Reduce time complexity to O(n) 🔗 My Submission: https://lnkd.in/gUZ5QUKc ☕ Spring Boot Learning 🔄 Hibernate Entity Lifecycle Deep Dive Today I didn’t just learn states… I understood how Hibernate actually behaves internally 👉 Transient – Only in heap memory 👉 Persistent – Connected & tracked by Hibernate 👉 Detached – Exists but not tracked 👉 Removed – Marked for deletion ⚡ Real Game Changer 💡 Persistence Context (First-Level Cache) 👉 Same entity = same reference 👉 Avoids repeated DB calls 👉 Managed automatically using @Transactional 🔥 Powerful Concept 👉 Updating entity WITHOUT calling save() still works Why? Because Hibernate tracks changes in Persistent State ⚡ This is called: Dirty Checking (not Dirty Read — common mistake 👀) 🧠 The Shift 👉 Efficient coding = smart data preparation 👉 Hibernate is not magic — it’s predictable when understood 👉 Backend = Data + Lifecycle + Optimization 📘 Spring Boot Notes: https://lnkd.in/gRgxP7Th 📈 Day 26 Progress: ✅ Improved hashmap intuition ✅ Understood Hibernate internals deeply ✅ Learned real-world DB optimization concept 💬 Did you know Hibernate updates data even without calling save()? 😄 #100DaysOfCode #BackendDevelopment #SpringBoot #Java #LeetCode #CodingJourney

  • text

To view or add a comment, sign in

Explore content categories