Find minimum time for irrecoverable password
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
Quick Answer: This question evaluates string-processing skills, combinatorial counting of substrings, simulation of time-based state changes, and algorithmic complexity analysis.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('abc', [1,2,3], 4)
Expected Output: 2
Explanation: After two attacks, at least four substrings contain a star.
Input: ('abcd', [2,4,1,3], 7)
Expected Output: 2
Explanation: Segment splitting tracks recoverable substrings.
Input: ('abc', [1,2,3], 0)
Expected Output: 1
Explanation: Already irrecoverable threshold returns 1.
Hints
- Track intact segments between attacked positions.
- Substrings with a star equal total substrings minus all-clean substrings.