Max Protected Population After One-Step-Left Relocation

Asked at Amazon · Coding Questions · Difficulty: Hard

Given `population[0..n-1]` and a binary string `unit` of the same length (`'1'` = a security unit in that city), each unit may move **one step left** (from city `i` to `i-1`) at most once; the unit in city 0 cannot move left. A city is *protected* if it holds a unit after relocations. Maximize the total population over protected cities (each protected city counts once).

Loading the problem…