mediumArrays

Unique Identifier Counter Solution

Problem Statement

You are given an array of integers `ids` where each integer represents a potential identifier. Your task is to determine the next available unique identifier. Implement a function `next_unique_id` that takes the array of `ids` as input and returns the smallest positive integer that is not present in the array.

Examples

Example 1:
Input:[1,2,3]
Output:4
Example 2:
Input:[1,2,4]
Output:3
Example 3:
Input:[-1,-2,0]
Output: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 Workspace

Tested Solutions

No solution code is currently loaded.
Complete this code in the workspace editor.