Practice Discrete Math

Algorithms / Points And Rectangles

Least You Need to Know: Points, Rectangles, Manhattan Distance, and Coordinate Checks

Coordinate interview problems reward small geometric invariants: compare min and max coordinates, use Manhattan distance when movement is axis-aligned, and rely on cross-product or area-style reasoning instead of fragile slope arithmetic when possible.

The least you need to know

Key notation

|x1-x2| + |y1-y2| Manhattan distance
(x2-x1)(y2-y1) axis-aligned rectangle area
cross((b-a),(c-a)) orientation/collinearity test

Tiny worked example

  • For points `(1, 2)` and `(4, 6)`, the Manhattan distance is `|1-4| + |2-6| = 7`.
  • If you instead need the area of the axis-aligned rectangle with opposite corners `(1, 2)` and `(4, 6)`, compute width `3` times height `4` to get `12`.

Common mistakes

How to recognize this kind of problem

Start practice