Search
⌘K

Leetcode 2837. Total Traveled Distance

Given a sequence of positions or movement updates, compute the total distance traveled by summing the distances between consecutive positions (absolute differences in 1D or Euclidean distances in 2D). The core challenge is a single-pass accumulation of those pairwise distances, correctly handling reversals and repeated positions.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.