Data Structures & AlgorithmsVery hardCodeforces Div2 E · DP optimisation

Problem: Which problem is classically solved by the 'convex hull trick' in DP with linear functions?

  1. A. Shortest path in a grid
  2. B. Minimising dp[i] = min_j (dp[j] + b_j * a_i) over all j < i
  3. C. Longest palindromic substring
  4. D. Topological sort

Correct answer: B. Minimising dp[i] = min_j (dp[j] + b_j * a_i) over all j < i

Each j contributes a line in a, and the lower envelope of lines answers the minimum quickly.

More Coding Interview Problems questions

Exams that ask this topic