#5Employee Management — Missing Employee ID
A company's employee management system assigns a unique positive integer ID to every employee. Due to employee resignations, data synchronization issues, or incomplete records, some employee IDs may be missing from the system.
You are given an unsorted array employeeIds, where each element represents an employee ID found in the current records. Return the smallest positive employee ID that is not present in the records.
Rules Every value in employeeIds is a valid positive employee ID. Employee IDs are integers greater than 0. Duplicate IDs may exist due to duplicate records. The array is unsorted.
Examples
Example 1
Input: employeeIds = [1,2,3,4]
Output: 5
Explanation: Employee IDs 1, 2, 3, and 4 are all present in the system. Therefore, the smallest employee ID that is not assigned is 5.
Example 2
Input: employeeIds = [1,2,3,5]
Output: 4
Explanation: Employee IDs 1, 2, 3, and 5 are present, but employee ID 4 is missing. Therefore, the smallest missing employee ID is 4.
Example 3
Input: employeeIds = [2,3,4,5]
Output: 1
Explanation: The employee records start from ID 2, so employee ID 1 is not present. Since 1 is the smallest possible positive employee ID, the answer is 1.
Constraints
- 1 <= employeeIds.length <= 100000
- 1 <= employeeIds[i] <= 10^9
- The array is not necessarily sorted.
