Mark Elements That Repeat Later

Problem Transform an array in place: each element becomes 1 if the SAME value appears again LATER in the array, else 0.

Input / Output

  • Input: int array. Output: 0/1 array per the rule.

Constraints

  • n up to 10^5; O(n) expected.

Example

  • [1,2,1,3,2] → [1,1,0,0,0] (the first 1 and first 2 repeat later; last occurrences and 3 do not).
asked …
LeaderboardSalaryAccount