← Cruise questions
CodingReported in a candidate post, May 2020

Array problem with O(n) math-trick solution

Filed under Cruise

The question

An array question that the candidate solved in O(n^2) with DP, while the interviewer wanted an O(n) solution using a mathematical trick.

No write-up yet. Related questions below have one.

Related Cruise questions

Collected from public candidate posts and coding forums. Updated Nov 2026.