interview playbook · communication scripts

What to say, word for word

You don't need to be a great talker. You need a few ready lines.

Learn them by heart, then say them in your own words. Ready lines leave your head free for the problem.

01

Before you write code

  • Clarifying the problem

    Ask first. Every question here saves you from solving the wrong problem.

    say

    • Let me restate the problem to make sure I have it right.
    • How large can n be? Roughly thousands, or millions?
    • Can the input be empty? Can it have negatives or duplicates?
    • If there is no valid answer, what should I return?
    • Is the input sorted, or should I not assume that?
  • Working through an example

    say

    • Let me work through a small example by hand first.
    • For this input I expect this output. Does that match what you have in mind?
  • Offering the brute force

    Saying the slow answer is not weak. It proves you can solve it, and gives you a base to improve.

    say

    • The simplest approach that works is to try every pair. That is O(n²).
    • I will start from this and look for the repeated work.
    • Should I code this first, or look for a faster approach?
  • Agreeing on the plan

    say

    • Here is my plan in three steps. Does it sound right to you before I code it?
    • This should take O(n) time and O(n) space. I am fine with that trade-off unless memory matters here.

02

While you think and code

  • Thinking aloud

    Say what you are trying, even if it might be wrong. Half an idea, said out loud, is better than silence.

    say

    • I am thinking about whether sorting helps here.
    • The slow part is this inner loop. Can I remember what I have already seen?
    • This looks like a sliding window, because we need the best contiguous subarray.
  • When you are stuck

    Being stuck is normal. Silence is the problem, not being stuck.

    say

    • Can I take a minute to think quietly?
    • I am stuck on how to avoid checking every pair. Let me try a different example.
    • Here is what I know so far, and here is the part I can't see yet.
  • Taking a hint

    A hint is a gift, not a mark against you. Repeat it back, then use it.

    say

    • That is a good point. So if the array is sorted, I can move two pointers inward.
    • Let me make sure I understand the hint: you mean I should store the counts first?
    • Thank you, that helps. Let me rework the plan with that.
  • Narrating code

    say

    • I will write the steps as comments first, then fill them in.
    • This loop moves the right pointer and grows the window.
    • I will use a helper method here to keep the main method short.

03

After the code

  • Testing

    say

    • Before I call it done, let me dry run it on the example.
    • Now the edge cases: an empty array, a single element, and all duplicates.
    • At this step, left is 0 and right is 2, so the sum is 9. That matches.
  • Admitting a bug

    Everyone writes bugs. Finding and fixing your own looks good.

    say

    • I see a bug here: this loop goes one step too far. Let me fix the bound.
    • You are right, that fails for an empty input. I will add a check at the top.
    • Good catch. The sum can overflow an int, so I will use a long.
  • Stating complexity

    Name n, then give time and space as two sentences, each with a reason.

    say

    • Let n be the length of the array.
    • Time is O(n log n) because of the sort. The scan after it is O(n).
    • Space is O(n) for the map. HashMap lookups are O(1) on average; with Integer keys, Java 8 and later keep the worst case at O(log n).
  • When you don't know

    Honest beats bluffing. Then show how you would find out.

    say

    • I am not sure about that. My guess is this, and here is how I would check it.
    • I have not used that before, but I would expect it to work like this.
  • Your questions at the end

    say

    • What does a normal week look like for someone in this team?
    • What would you expect a new engineer to own in the first three months?