An in-memory file vault must assign a unique name whenever a file is created. If the requested name already exists, append a parenthesized positive integer to obtain an unused name.
Implement `allocate_names(requests: string[]) -> string[]` and return the assigned name for each request in order.
### Constraints & Assumptions
- All requests target the same namespace, which starts empty. No file is deleted or renamed during the sequence.
- If requested name `s` is unused, assign `s` unchanged.
- Otherwise choose the smallest positive integer `x` for which `s + "(" + decimal(x) + ")"` is unused, then reserve and return that name.
- Names are case-sensitive, nonempty ASCII strings of at most 100 characters. There are at most 10,000 requests.
- Parentheses already present in a requested name are literal text. For example, a collision on `a(1)` tries `a(1)(1)`; do not reinterpret it as a collision on `a`.
- The smallest available positive suffix and flat namespace are explicit practice choices for the reported duplicate-name behavior.
### Examples
```text
requests = ["report", "report", "report", "report(1)"]
result = ["report", "report(1)", "report(2)", "report(1)(1)"]
```
```text
requests = ["a(1)", "a", "a", "A"]
result = ["a(1)", "a", "a(2)", "A"]
```
```hint Remember where each repeated base can resume
Once a suffix candidate is known to be occupied and names are never removed, trying the same candidate again for that base cannot succeed.
```
Overview: Allocate unique vault file names with the smallest available numeric suffix, handling preexisting suffixes, repeated requests, and case sensitivity.
An in-memory file vault must assign a unique name whenever a file is created. If the requested name already exists, append a parenthesized positive integer to obtain an unused name.
Implement allocate_names(requests: string[]) -> string[] and return the assigned name for each request in order.
Constraints & Assumptions
All requests target the same namespace, which starts empty. No file is deleted or renamed during the sequence.
If requested name
s
is unused, assign
s
unchanged.
Otherwise choose the smallest positive integer
x
for which
s + "(" + decimal(x) + ")"
is unused, then reserve and return that name.
Names are case-sensitive, nonempty ASCII strings of at most 100 characters. There are at most 10,000 requests.
Parentheses already present in a requested name are literal text. For example, a collision on
a(1)
tries
a(1)(1)
; do not reinterpret it as a collision on
a
.
The smallest available positive suffix and flat namespace are explicit practice choices for the reported duplicate-name behavior.