mediumArrays
Unique Identifier Allocation Solution
Problem Statement
You are given an array of integers `ids` where each element represents a potential identifier. Your task is to determine whether each identifier is new or already exists in the array. Implement a function that returns a list of integers where each element corresponds to the input `ids` array, with 1 indicating a new identifier and 0 indicating an existing identifier.
Examples
Example 1:
Input:{"ids":[1,2,3,1,2,4]}
Output:[1,1,1,0,0,1]
Example 2:
Input:{"ids":[5,5,5,5]}
Output:[1,0,0,0]
Example 3:
Input:{"ids":[10,20,30,40]}
Output:[1,1,1,1]
Time: O(N) Space: O(1)
Analyze constraints and compute optimal solutions step-by-step.
Run, Test & Submit Code
Ready to practice this challenge? Launch our interactive compilation environment with compiler validation.
Solve on Interactive WorkspaceTested Solutions
No solution code is currently loaded.
Complete this code in the workspace editor.
