Pregunta de entrevista de ThoughtSpot

A Binary Search Problem and a DP problem.