📝Today I Learned
25 posts
Show
- Graph Day: Reusing the Same Engines Again— Course Schedule, Clone Graph, and Word Ladder — three very different problems, but each one reused an engine I already built for something else.#today-i-learned#algorithm#graph#bfs#dfs#leetcode#python3 min read
- Tree Day: Same BFS Engine, a New Kind of Ancestor Chase— Level Order reused grid BFS's snapshot trick outright. Validate BST needed a range from every ancestor, not just the parent. And LCA with parent pointers turned out to be linked list intersection in disguise.#today-i-learned#algorithm#tree#bst#bfs#leetcode#python2 min read
- Meeting Rooms III: Two Heaps, One Delayed Start— Meeting Rooms III needs two heaps instead of one, because now both 'is a room free' and 'which specific room' matter at the same time. A delayed meeting keeps its original duration, not its original end time.#today-i-learned#algorithm#heap#sweep-line#leetcode#python2 min read
- Car Pooling: Weighted Sweep, Bounded Coordinates, and Knowing Who Broke Capacity— Car Pooling is Meeting Rooms II with weighted events. Three ways in: a bucket array when stations are bounded, sorted events when they're not, and a heap when I need to know which trip caused the overflow.#today-i-learned#algorithm#heap#sweep-line#leetcode#python2 min read
- Interval Day: One Sweep, Three Ways to Line Up Time— Merge Intervals, Insert Interval, and Meeting Rooms II solved three ways — heap, two pointers, and a bucket array. Plus the question that splits them all: do I need to know WHICH room, or just HOW MANY?#today-i-learned#algorithm#intervals#heap#leetcode#python2 min read
- Stack Day: Valid Parentheses to LRU Cache — Counters vs Stacks, Min Stack Tricks, and Designing for O(1)— Count problems take a counter, order problems take a stack. Min Remove stores indexes because deletion needs positions. Min Stack keeps a history because pop must restore. And LRU Cache is a hashmap that answers 'where' married to a linked list that answers 'who's oldest'.#today-i-learned#algorithm#stack#design#leetcode#python2 min read
- Grid BFS in One Day: Islands, Rotting Oranges, Flood Fill, and Three Silent Bugs— Four grid BFS problems, one skeleton. Mark visited when enqueuing. Multi-source BFS counts time in queue levels. Three ways to block revisits. And three bugs that failed silently — '1' vs 1, wrong tuple enqueued, == where = was meant.#today-i-learned#algorithm#bfs#leetcode#python2 min read
- Factory Pattern: One Place to Build Anything— Callers should say what they want, never how it's built. Factory centralizes creation so the rest of the code never touches a constructor.#today-i-learned#design-pattern#kotlin#android2 min read
- Observer Pattern: Broadcasting Without Knowing Who's Listening— One state change, many reactions, zero direct dependencies. The subject just notifies a list — it never needs to know what any observer does with it.#today-i-learned#design-pattern#kotlin#android1 min read
- Strategy Pattern: Swappable Algorithms Behind One Interface— Same goal, different algorithms, one interface. Strategy replaces if/else chains with a family of classes — and it turns out Decorator and Builder are just the natural next steps.#today-i-learned#design-pattern#kotlin#android1 min read