Miscellaneous Topics
A curated collection of problems spanning Recursion, Simulation, Geometry, Concurrency, and other specialized categories.
What's Included
- Recursion: Tree and divide-and-conquer problems solved purely recursively.
- Simulation: Step-by-step rule following — game of life, robot movement, etc.
- Geometry: Computational geometry — convex hull, line intersection, polygon area.
- Concurrency: Multi-threading patterns — semaphores, barriers, print-in-order.
- Constructive Algorithms: Build a valid answer from scratch using clever construction.
- JavaScript: JS-specific interview problems using closures, Promises, and prototypes.
Cheatsheet Formulas
- Recursion base case: Always define a base case. Think: "smallest valid input?"
- Simulation: Model state explicitly. Advance step by step. Use modular indexing for cyclic boards.
- Triangle area (3 points):
|x1(y2-y3) + x2(y3-y1) + x3(y1-y2)| / 2 - Concurrency — semaphore:
acquire()before critical section,release()after. - Direction arrays:
dirs = [[0,1],[0,-1],[1,0],[-1,0]]for 4-directional grid traversal.