How would you find the first character in a string that doesn't repeat?
What they're checking
Whether you can get from a brute-force idea to an efficient one, and explain why it is efficient.
A strong answer covers
- Restate the problem and ask about edge cases, such as an empty string or which characters can appear.
- Mention the brute-force check of every pair, then improve on it by counting each character in a hash map.
- Scan the string a second time and return the first character with a count of one.
- State the cost, O(n) time and O(k) extra space for k distinct characters, and test it on a short example.