The Codetikki cartographers jumbled the sequence [0, 1, ..., N] and the only clue is an array of signs indicating whether each number is larger (+) or smaller (-) than the previous one. Given an array of signs (with None as the first element), reconstruct an array consistent with it. Output the reconstructed array as space-separated integers.
Example 1:
Example 2:
Constraints:
1 <= N <= 10^5 The input always has a valid solution
Tags:
