Skip to content
  • Dashboard
  • Review
  • Go: plan & chat
  • Roadmap
  • Patterns & lessons49
  • Sheets
  • Problems1.5k
  • Ascend
  • Toolkit
  • Core CS + SQL
  • System Design
  • Machine Coding
  • Interview hub
  • Mock interview
  • Companies & OA
  • Leaderboard
  • Battles
  • College Cup
  • People

Keep your progress

Sync across devices with a free account.

Sign upSign in
Patterns & lessons
Sign inSign up
Patterns/Math & Number Theory/Computational Geometry Primitives

Technique

Convex Hull (Andrew's monotone chain)

Sort points and build lower and upper hulls with a stack that pops non-left turns, in O(n log n).

Learn firstComputational Geometry PrimitivesMonotonic Stack
0%
mastery
0/1 solved
Practise nextConvex Hull
IdeaPracticePitfalls

Recognise it

The signal

smallest fence around points

  1. 1Brute force

    Check every pair as a potential hull edge O(n3).

  2. 2The observation

    Pair checks: sorted order plus a turn test keeps only hull vertices on the stack.

  3. 3Why it works

    The stack always forms a convex chain of the processed points.

Reach for it when

  • +farthest pair (rotating calipers)
  • +lower envelope of lines (dual of CHT)

Not when

  • ×collinear points requirement differs (keep or drop)

Practice

Next

Convex Hull

0/1 solved
  • Convex HullCSESMedium

Pitfalls

Misconceptions

  • !dropping collinear boundary points when the problem wants them
Go deeperresources

Resources

  • Binary exponentiationcp-algorithms · article
  • Sieve of Eratosthenescp-algorithms · article
  • Modular inversecp-algorithms · article
  • DivisibilityUSACO Guide · course
  • CombinatoricsUSACO Guide · course
  • Math cheatsheetTech Interview Handbook · article
TodayReviewPatternsProblems