Some LeetCode problems look deceptively simple... until the Time Limit Exceeded (TLE) hits. ��
Just solved 239. Sliding Window Maximum.
My first intuition? Track the max, and rescan the window when it drops off.
Result: O(N . K) time complexity. TLE! 💀 🧵👇
The fix brought the solution down to O(N) time and beats 93% of solutions on LeetCode 😌
It’s always satisfying when a problem forces you to look past the "quick fix" and get clever with data structures.
check out my solution on LC : https://t.co/rs7Nmd3dIp
Don't just set a random 5-minute TTL and hope for the best. Design event-driven cache invalidation when state changes.
Which cache strategy do you rely on most in production?
Caching can drop your API latency from 250ms to 12ms.
It can also serve stale data to thousands of users if you pick the wrong pattern.
Here are the 3 core caching strategies every senior engineer must know 🧵👇
3. Write-Back: App writes to Cache immediately. DB is updated asynchronously later. Blazing fast writes, but high risk: if the cache node dies before syncing, data is lost.
Rule of thumb: Scale your domain boundaries and team structure first. Scale your underlying infrastructure second.
What’s your take, monolith first or microservices from day one?
We didn’t need microservices. We just needed to stop treating our monolith like a dumping ground.
Here is why splitting your database and services prematurely might be slowing your team down 🧵👇
Before distributing your system, build a Modular Monolith.
Enforce strict domain boundaries inside a single codebase. If you can't keep modules isolated in memory, splitting them across network boundaries will just create a distributed monolith.