Amazon·Software Engineer·Onsite - Coding / Algorithms
- You have a password string of length n. An attack sequence is given as a permutation of positions, and at each second t, the character at that position gets replaced with '*'. The password is considered irrecoverable once the number of substrings containing at least one '*' reaches or exceeds some threshold m. Find the minimum time t at which this happens. If it's already irrecoverable before any attack, return 1. Walk through your algorithm and give time and space complexity.
“My first instinct was to just simulate it naively, count all substrings after each replacement, and check against m.”