Classic

6 articles

dsa10 min read

Aggressive Cows — Binary Search on Answer (SPOJ / GFG Classic)

Place C cows in N stalls to maximise the minimum distance between any two cows. Learn the canonical binary-search-on-answer pattern — the template behind Magnetic Force Between Two Balls, Split Array, and dozens of other hard problems.

Read →
dsa9 min read

Guess Number Higher or Lower — Binary Search with API [LC 374]

Find the secret number between 1 and n using the guess() API in O(log n) calls. Master the exact binary search template used in all interactive/guessing problems and understand why the API return values map directly to the lo/hi update rules.

Read →