Smallest Absent Positive Multiple
Company: Bloomberg
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
You are given an integer array `nums` and a positive integer `k`. Return the smallest positive integer divisible by `k` that does not appear in `nums`.
```cpp
class Solution {
public:
int missingMultiple(vector<int>& nums, int k);
};
```
### Examples
**Example 1:**
```text
Input: nums = [3,6,6,12], k = 3
Output: 9
Explanation: The positive multiples 3 and 6 are present, but 9 is missing. The second copy of 6 does not fill that gap, and the later multiple 12 does not change the answer.
```
**Example 2:**
```text
Input: nums = [100], k = 100
Output: 200
Explanation: The first positive multiple, 100, appears. The next one, 200, does not, so it is the answer even though input elements are bounded by 100.
```
### Constraints
- `1 <= nums.length <= 100`.
- `1 <= nums[i] <= 100`.
- `1 <= k <= 100`.
### Clarifying Questions
- Does zero qualify as a candidate? No; the result must be positive.
- Can input values repeat? Yes. Presence, not the number of copies, matters.
- Are only array values divisible by `k` relevant to a candidate's presence? Yes; other values cannot equal that candidate.
- Must the result itself lie within the input-value bound? No.
### What a Strong Answer Covers
- The positivity, divisibility, absence, and smallest-value conditions together.
- Duplicate entries and a missing first multiple.
- An answer beyond the largest allowed input value.
- A termination argument and resource bounds using the actual constraints.
### Follow-up Questions
- Why do repeated copies of an input value not change the answer?
- How would requesting the first several absent positive multiples change the output contract?
```hint Test multiples using value presence
Record which values occur. Examine positive multiples of k in increasing order and stop at the first absent one. The small input-value bound can simplify the presence representation.
```
Overview: Find the smallest absent positive multiple of k. Includes duplicate values, answers beyond the input bound, examples, proof, and a C++ solution.