Tic-tac-toe bot, Part 2: minimax, with a small game tree

Tic-Tac-Toe Minimax Algorithm in Java

In Part 1, I built a tic-tac-toe bot with a layered brain: 7 small strategies, asked one by one. It worked. I couldn’t beat it anymore. But it was hard to scale. A bigger board needs more conditions, and every new condition is one more place for things to break. It also couldn’t really look ahead. Only two of the strategies, Fork and BlockFork, thought about the next move. The rest just read the board as it is right now. ...

November 12, 2026 · 7 min · 1474 words · Hitesh Patel
A tic-tac-toe board with a robot holding a sword and a shield

Unbeatable Tic-Tac-Toe AI: 7 Rules in Java

My first bot picked squares at random. I beat it in 3 moves. I’m working through LLD problems, and tic-tac-toe was the third one I picked. Building it for two players was the easy part. Then I added a bot, and it hooked me for days. Every time I beat it, I added a new rule. Every time I added a rule, I found a new way to beat it. This went on until one day I just… couldn’t win anymore. Only draws. ...

November 10, 2026 · 8 min · 1662 words · Hitesh Patel
Low-level design diagram of a parking lot system showing floors, spots, vehicles, and ticket flow

Parking Lot LLD — What I Learned Building It

I recently started practicing Low Level Design problems to strengthen my system design and backend thinking. The second problem I picked was the classic Parking Lot System. At first, it looked simple. But while building it, I realized these problems are less about writing code and more about: Modeling real-world systems Managing state correctly Designing scalable abstractions Avoiding bad object-oriented practices Code Repo parking lot Requirements The system supports: Multiple parking floors Different parking spot types: Small Medium Large Multiple vehicle types: Bike Car Truck Ticket generation at entry Fee calculation during exit based on parking duration Initial Flow After reading the requirements, this was the initial flow I designed: ...

May 10, 2026 · 4 min · 644 words · Hitesh Patel
Low-level design diagram of an elevator system using active and shadow queue strategy

Elevator System Design LLD - Active & Shadow Queue

In the Previous attempt we designed an elevator system using two queues — an up queue and a down queue. But that system had some problems. It changed direction abruptly and did not respect the order of requests. To overcome this, the system has been redesigned with an active and shadow queue strategy that better mirrors how a real elevator behaves. The Requirements The requirements remain the same as the original design: ...

April 24, 2026 · 9 min · 1810 words · Hitesh Patel
Low-level design diagram of a single elevator system with queue-based SCAN scheduling

Elevator System Design (LLD): Single Lift Scheduling Explained

I have started learning low level system design and elevator is the first problem i picked up. In this i have picked the single elvator for simplicity and not get overwhelmed by it and get demotivated. So I built an elevator system. Lets improve this in stages. Not because it’s trendy. I have thought countless times standing in elevator does how it works. and after this i have my answer. ...

April 22, 2026 · 8 min · 1532 words · Hitesh Patel