Live coding is half the interview.
Live coding é metade da entrevista.Aula
Entrevista técnica B2: coding discussion
Nível: B2
Objetivo
Comunicar raciocínio durante uma entrevista de live coding em inglês: pensar em voz alta, explicar trade-offs de complexidade, discutir edge cases, abordagem de teste, e refactor sem virar código mudo nem monólogo.
Explicação
Coding discussion B2 não é sobre 'escrever o código perfeito', é sobre mostrar como você pensa enquanto escreve. O entrevistador quer ver o processo: como você decompõe o problema, como você nomeia variáveis, como você decide entre abordagens, e como você reage quando o caminho inicial não funciona. O silêncio é o pior inimigo: se você fica em silêncio por 2 minutos, o entrevistador não sabe se você está travado ou pensando.
A estrutura canônica é: rephrase the problem ('so the function takes X and returns Y, with the constraint Z'), propose a first approach ('the simplest approach is ... with O(n) time and O(1) space'), think aloud while coding, name the trade-off explicitly ('I am choosing a HashMap here because the lookup is O(1) but the memory is O(n)'), discuss edge cases ('what if the input is empty? what if the values are negative?'), write tests before claiming done, e suggest a refactor ('in production I would extract this into a helper with a clearer name').
Marcadores verbais B2: 'let me make sure I understand the contract', 'I am going to start with the simplest approach', 'I will write a small test for the empty case first', 'I notice this is O(n²) — let me think if that fits the constraint', 'in production I would add ...', 'could we walk through this example together'. Eles mostram processo. O oposto é escrever código mudo, defender o primeiro approach, e não falar quando o caminho trava.
Erros comuns: ficar em silêncio, defender o primeiro código sem pensar em edge case, não escrever testes, não falar de complexidade, e fechar sem 'o que eu faria diferente em produção'. O bom candidato B2 trata a entrevista como uma conversa técnica, não um exame silencioso.
Exemplos
| Inglês | Tradução | Observação |
|---|---|---|
| Let me make sure I understand the contract: the function takes a list and a target, and returns the indices. | Deixa eu ter certeza de que entendi o contrato: a função recebe uma lista e um alvo, e retorna os índices. | Rephrase o problema antes de codar; mostra que você ouviu. |
| I am going to start with the simplest approach: a brute force with two nested loops, O(n²). | Vou começar com a abordagem mais simples: força bruta com dois loops aninhados, O(n²). | First approach explícito; ancorado em complexidade. |
| I notice this is O(n²) — let me think if that fits the constraint. | Eu noto que isso é O(n²) — deixa eu pensar se cabe na restrição. | Autoavaliação durante o coding; pivota quando a restrição não cabe. |
| I will write a small test for the empty case first. | Vou escrever um teste pequeno para o caso vazio primeiro. | Testar edge case cedo; não só no final. |
| In production I would extract this into a helper with a clearer name, like 'find_pair_sum'. | Em produção eu extrairia isso em um helper com um nome mais claro, como 'find_pair_sum'. | Refactor com nome melhor; clareza de produção. |
| Could we walk through this example together to make sure I have the right invariant? | Podemos percorrer este exemplo juntos para garantir que eu tenho o invariante certo? | Convite ao entrevistador; mostra processo. |
| I am choosing a HashMap here because the lookup is O(1) but the memory is O(n). | Estou escolhendo um HashMap aqui porque a busca é O(1) mas a memória é O(n). | Trade-off explícito durante o coding. |
| I am stuck on the recursion; let me write a small example on paper before continuing. | Estou travado na recursão; deixa eu escrever um pequeno exemplo no papel antes de continuar. | Reconhecer bloqueio + pedir espaço, sem ficar em silêncio. |
Erros comuns
- Ficar em silêncio: o entrevistador não sabe se você está pensando ou travado; pense em voz alta.
- Defender o primeiro approach sem pensar em edge case: o código pode estar certo para o exemplo, mas quebrar em produção.
- Não escrever testes: testes durante o interview mostram processo, não perfeccionismo.
- Não falar de complexidade: 'isto é O(n)' ancora a conversa em critério, não em opinião.
- Fechar sem 'o que faria diferente em produção': perde a chance de autoavaliação honesta.
- Não reagir a feedback do entrevistador: 'boa observação, vou ajustar' é o processo, não defesa.
- Escrever código com nomes ruins: nomes ruins são uma escolha; nomes claros mostram maturidade.
- Pedir tempo sem dizer o que está fazendo: 'me dá um minuto' é menos útil que 'deixa eu escrever um exemplo no papel'.
Prática guiada
Reescreva cada momento abaixo no padrão B2 de coding discussion. O objetivo é pensar em voz alta, ancorar em trade-off, falar de complexidade, e fechar com autoavaliação.
- Silêncio: o candidato fica 2 minutos sem falar.
→ Versão B2: *Let me make sure I understand the contract. I am going to start with a brute force, two nested loops, O(n²). I notice this might be too slow for the constraint; let me think about a HashMap approach, O(n) time and O(n) space.* Explicação: rephrase + first approach + trade-off de complexidade.
- Defender primeiro código: 'Está certo, pronto.'
→ Versão B2: *Let me walk through the edge cases: empty input, single element, target not in list. I will write a small test for the empty case first. In production I would extract this into a helper with a clearer name.* Explicação: edge cases + teste + refactor.
Resumo
Coding discussion B2 é pensar em voz alta enquanto codifica: rephrase, first approach com complexidade, think aloud, trade-offs explícitos, edge cases, testes, e fechamento com autoavaliação. Marcadores: *let me make sure I understand the contract*, *I am going to start with the simplest approach*, *I notice this is O(n²)*, *in production I would ...*, *could we walk through this example together*. O silêncio é o pior inimigo.
Vocabulário
Palavras principais
Always think aloud during the interview.
Sempre pense em voz alta durante a entrevista.Let me make sure I understand the contract.
Deixa eu ter certeza de que entendi o contrato.I'll start with a brute force, then optimize.
Começo com força bruta, depois otimizo.Time complexity is O(n), space is O(1).
Complexidade de tempo é O(n), de espaço O(1).What about the empty input edge case?
E o caso de borda de entrada vazia?What is the invariant in this loop?
Qual é o invariante neste loop?I would refactor this for clarity in production.
Eu refatoraria isso para clareza em produção.The code is not production ready yet.
O código ainda não está pronto para produção.Let me rephrase the problem in my own words.
Deixa eu reformular o problema com minhas palavras.I always write a test for the empty case first.
Eu sempre escrevo um teste para o caso vazio primeiro.I am stuck on the recursion; let me write an example.
Estou travado na recursão; deixa eu escrever um exemplo.Can we walk through this example together?
Podemos percorrer este exemplo juntos?A HashMap gives O(1) lookup at the cost of O(n) memory.
Um HashMap dá busca O(1) ao custo de O(n) de memória.A two-pointer technique can solve this in O(n).
A técnica de dois ponteiros resolve em O(n).I would add memoization to avoid recomputing.
Adicionaria memoização para evitar recomputar.Good naming is part of the solution.
Boa nomeação é parte da solução.Let me walk through an example to validate the invariant.
Deixa eu percorrer um exemplo para validar o invariante.História
História: Entrevista técnica B2: coding discussion
Nível: B2
História em inglês
Opening the live coding
The interviewer asked Priya to solve a 'two sum' variant live. Priya started by rephrasing the contract. She said, let me make sure I understand the contract: the function takes a list of integers and a target, and returns the indices of the two values that sum to the target. She added the constraint: the solution must be faster than O(n²). She then said, I am going to start with a brute force, two nested loops, O(n²), and then optimize if needed. She wrote the brute force on the whiteboard while thinking aloud.
Self-evaluation and pivot
After the brute force worked for the example, Priya self-evaluated. I notice this is O(n²), which does not fit the constraint of O(n), she said. The interviewer asked, what would you do instead? Priya answered, I am choosing a HashMap here because the lookup is O(1) but the memory is O(n). The trade-off fits the constraint, she added. She coded the HashMap approach, then wrote a small test for the empty input case first. She walked through the edge cases: empty input, single element, target not in list.
Closing with refactor for production
The code worked for all the cases. Priya paused and added, in production I would extract this into a helper with a clearer name, like 'find_pair_sum'. She added, I would also add an explicit type for the input and the output, and a docstring with the complexity. The interviewer asked, what was the trickiest part? Priya said, I am stuck on the recursion at first, so I switched to a HashMap and validated with a small example on paper before coding. The interviewer nodded; Priya had shown rephrase, first approach, complexity-aware pivot, edge cases, and a production refactor.
Tradução linha por linha
| Inglês | Tradução |
|---|---|
| The interviewer asked Priya to solve a 'two sum' variant live. | O entrevistador pediu para Priya resolver uma variante de 'two sum' ao vivo. |
| Priya started by rephrasing the contract. | Priya começou reformulando o contrato. |
| She said, let me make sure I understand the contract: the function takes a list of integers and a target, and returns the indices of the two values that sum to the target. | Ela disse: deixa eu ter certeza de que entendi o contrato: a função recebe uma lista de inteiros e um alvo, e retorna os índices dos dois valores que somam ao alvo. |
| She added the constraint: the solution must be faster than O(n²). | Ela adicionou a restrição: a solução precisa ser mais rápida que O(n²). |
| She then said, I am going to start with a brute force, two nested loops, O(n²), and then optimize if needed. | Então ela disse: vou começar com força bruta, dois loops aninhados, O(n²), e depois otimizar se necessário. |
| She wrote the brute force on the whiteboard while thinking aloud. | Ela escreveu a força bruta no quadro enquanto pensava em voz alta. |
| After the brute force worked for the example, Priya self-evaluated. | Depois que a força bruta funcionou para o exemplo, Priya se autoavaliou. |
| I notice this is O(n²), which does not fit the constraint of O(n), she said. | Eu noto que isso é O(n²), o que não cabe na restrição de O(n), ela disse. |
| The interviewer asked, what would you do instead? | O entrevistador perguntou: o que você faria em vez disso? |
| Priya answered, I am choosing a HashMap here because the lookup is O(1) but the memory is O(n). | Priya respondeu: estou escolhendo um HashMap aqui porque a busca é O(1) mas a memória é O(n). |
| The trade-off fits the constraint, she added. | O trade-off cabe na restrição, ela adicionou. |
| She coded the HashMap approach, then wrote a small test for the empty input case first. | Ela codificou a abordagem HashMap, então escreveu um pequeno teste para o caso de entrada vazia primeiro. |
| She walked through the edge cases: empty input, single element, target not in list. | Ela percorreu os casos de borda: entrada vazia, elemento único, alvo não presente. |
| The code worked for all the cases. | O código funcionou para todos os casos. |
| Priya paused and added, in production I would extract this into a helper with a clearer name, like 'find_pair_sum'. | Priya fez uma pausa e adicionou: em produção eu extrairia isso em um helper com um nome mais claro, como 'find_pair_sum'. |
| She added, I would also add an explicit type for the input and the output, and a docstring with the complexity. | Ela adicionou: também adicionaria um tipo explícito para a entrada e a saída, e uma docstring com a complexidade. |
| The interviewer asked, what was the trickiest part? | O entrevistador perguntou: qual foi a parte mais difícil? |
| Priya said, I am stuck on the recursion at first, so I switched to a HashMap and validated with a small example on paper before coding. | Priya disse: fiquei travada na recursão no começo, então mudei para um HashMap e validei com um pequeno exemplo no papel antes de codar. |
| The interviewer nodded; Priya had shown rephrase, first approach, complexity-aware pivot, edge cases, and a production refactor. | O entrevistador assentiu; Priya tinha mostrado rephrase, primeiro approach, pivô consciente de complexidade, casos de borda e refactor de produção. |
Notas de vocabulário
- let me make sure I understand the contract = rephrase B2; mostra que você ouviu antes de codar.
- I am going to start with a brute force, two nested loops, O(n²) = first approach explícito + complexidade; ancoragem em critério.
- I notice this is O(n²), which does not fit the constraint of O(n) = autoavaliação durante o coding; pivota quando a restrição não cabe.
- I am choosing a HashMap here because the lookup is O(1) but the memory is O(n) = trade-off explícito + escolha com razão.
- the trade-off fits the constraint = ancora a escolha na restrição, não em opinião.
- I will write a small test for the empty input case first = teste de edge case cedo; mostra processo.
- she walked through the edge cases: empty input, single element, target not in list = edge cases explícitos, em vez de assumir que o exemplo basta.
- in production I would extract this into a helper with a clearer name, like 'find_pair_sum' = fechamento com refactor de produção; autoavaliação honesta.
- I am stuck on the recursion at first, so I switched to a HashMap = reconhecer bloqueio + plano, em vez de ficar em silêncio.
Perguntas de compreensão
- Why did Priya start by rephrasing the contract instead of jumping to code?
- What was Priya's first approach, and why did she name the complexity explicitly?
- How did Priya react when she realized the brute force did not fit the constraint?
- What was the trade-off of the HashMap approach, and why did she say it fits the constraint?
- Why did Priya write a small test for the empty case first, before claiming done?
- What was Priya's closing move, and what did it show?
- How did Priya handle being stuck on the recursion?
- Why is thinking aloud the most important B2 signal in live coding?
- What would have been wrong with 'I think this is done' as a closing line?
Prática com a história
- Reescreva: 'Vou começar a programar.' (coding discussion B2)
- Reescreva: 'Está certo, sem mais nada para discutir.' (coding discussion B2)
- Reescreva: 'Não sei o que fazer agora.' (coding discussion B2)
- Reescreva: 'Vou usar HashMap.' (coding discussion B2 com trade-off)
- Traduza: 'Eu noto que isso é O(n²) — deixa eu pensar se cabe na restrição.'
- Traduza: 'Estou travado na recursão; deixa eu escrever um pequeno exemplo no papel antes de continuar.'
Prática
Exercícios e teste
A próxima melhoria é transformar esses arquivos em perguntas com resposta no navegador. Por enquanto, esta página já organiza o estudo e permite seguir a aula inteira sem abrir os arquivos manualmente.