Data Structures & AlgorithmsVery hardCodeforces Div2 E · DP optimisation
Problem: Which problem is classically solved by the 'convex hull trick' in DP with linear functions?
- A. Shortest path in a grid
- B. Minimising dp[i] = min_j (dp[j] + b_j * a_i) over all j < i
- C. Longest palindromic substring
- 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
- Problem: What is the cost of inserting into a binary search tree that is perfectly balanced with n nodes?
- Problem: Which concept explains why the smallest enclosing circle is determined by at most three boundary points?
- Problem: Which statement about the Hungarian algorithm's time complexity is correct for an n x n assignment problem?
- Problem: What is the purpose of the 'Floyd cycle detection' algorithm?
- Problem: What is the Euler characteristic relation used for planar graphs?
- Problem: How many monotone (right and up) lattice paths from (0,0) to (5,7) pass through the point (2,3)? Run the code. python from math…