Почему молчать нельзя
На лайв-кодинге интервьюер оценивает не только код, но и ход мысли. Если ты молчишь десять минут, он не понимает, где ты и как помочь. На английском это ещё важнее: молчание часто выглядит как «не понял задачу».
Хорошая новость: для этого хватает двадцати фраз. Их можно выучить заранее.
Этапы и фразы
1. Уточнить условие
- Let me make sure I understand the problem.
- Can I assume the input is always sorted?
- What should happen if the array is empty?
- Are there any constraints on the input size?
2. Пример и идея
- Let me walk through a small example.
- The brute-force approach would be to check every pair, which is O(n squared).
- I think we can do better with a hash map.
3. План
- Here's my plan: first ..., then ..., and finally ...
- Does that sound reasonable before I start coding?
4. Код
- I'll start with a helper function that ...
- Here I'm iterating over ...
- I'm using a set here because lookups are constant time.
5. Проверка и сложность
- Let me trace through the example.
- I think there's an off-by-one error here.
- The time complexity is O(n), and space is O(n) because of the map.
6. Если застрял
- Let me think about this for a second.
- I'm a bit stuck on the edge case with duplicates.
- Could you give me a hint? (это нормально, лучше, чем молчать пять минут)
Как читать сложность вслух
- O(1): constant time / O of one
- O(n): linear / O of n
- O(n log n): n log n
- O(n²): O of n squared / quadratic
Частые ошибки
- Полная тишина. Даже I'm thinking about the edge cases лучше, чем ничего.
- «How to say...». Если не знаешь слова, опиши: the thing that stores unique values (set).
- Сразу код без плана. Интервьюер может подсказать, если план кривой.
- «I will do it» вместо «I'll». Без сокращений речь звучит механически.
- Не спросить про крайние случаи. На английском это edge cases или corner cases.
Что спросят на собесе
- Can you walk me through your approach?
- What's the time and space complexity?
- Can you think of any edge cases?
- Can we do better?
- How would you test this?