AlgoDaily

Mock Interviews

Read at your own pace. Code execution, quizzes, progress tracking, and the AI tutor are available in the interactive view with JavaScript enabled.

Why Mock Interviews

From learning tools to performing under pressure

You have now seen the core interview toolkit: arrays, strings, hashing, stacks, queues, linked lists, trees, graphs, recursion, dynamic programming, greedy choices, and even System Design Basics.

A mock interview is where those separate skills become one repeatable performance.

In a real interview, especially at a finance-focused firm like Jane Street, the interviewer is not only checking whether you can code. They are also watching how you:

  • clarify ambiguity,
  • choose a data structure on purpose,
  • explain tradeoffs,
  • recover from mistakes,
  • test edge cases,
  • analyze cost clearly.

Today we will practice the interview process itself, not a new algorithm pattern.

Why Mock Interviews

The Interview Loop

A repeatable structure

When you feel confused, do not start typing faster. Return to the loop.

Mock interview loop:

  1. Restate the problem in your own words.
  2. Clarify inputs, outputs, constraints, and edge cases.
  3. Explore a simple approach first.
  4. Improve using the tools from earlier lessons.
  5. Code the chosen approach cleanly.
  6. Test with normal, edge, and tricky cases.
  7. Analyze time and space.

This keeps you from jumping randomly between ideas.

A strong candidate sounds like: “Let me first confirm the requirement. Then I’ll discuss a simple solution, look for a better data structure, code it, and test it.”

The Interview Loop

Clarify Before Coding

Ambiguity is part of the test

Interview prompts are often intentionally short. Your first job is to remove uncertainty.

Suppose the prompt is:

Given a list of trade IDs, return the first duplicate ID.

Before coding, ask:

  • Should “first duplicate” mean first value whose second occurrence appears earliest?
  • Are trade IDs strings, integers, or mixed?
  • Can the list be empty?
  • Should the comparison be case-sensitive?
  • Do we return the ID, the index, or None if no duplicate exists?

These questions are not wasting time. They prevent solving the wrong problem.

A finance interview may use trading examples, but the underlying move is usually something familiar from Hashing and Hash Tables or Arrays and Strings.

Clarify Before Coding

Best First Move

You receive this prompt:

Given a list of numbers, return whether any value appears twice.

What is the best first response in a mock interview?

Speak Your Reasoning

Think aloud, but stay organized

Many beginners either go completely silent or narrate every tiny keystroke. Aim for the middle.

Use short reasoning checkpoints:

  • “The brute force way compares every pair.”
  • “That repeats work, so I want a structure for fast lookup.”
  • “A set lets me remember values I have already seen.”
  • “If I see a value already in the set, I can return immediately.”

Notice the pattern: problem observation → data structure choice → reason.

This is how you show the interviewer that you are not just memorizing code. You are selecting tools from the course deliberately.

Speak Your Reasoning

Silent Coding

True or false:

During a mock interview, it is best to code silently until the full solution is finished, because talking may distract the interviewer.

Code With Intent

A clean mock-interview answer

Here is a compact example for the duplicate-number prompt.

Notice the interview-friendly structure:

  1. clear function name,
  2. simple variable names,
  3. early return when the answer is known,
  4. small tests printed at the bottom.

This uses the set pattern from Hashing and Hash Tables without re-explaining hashing from scratch.

```python
def contains_duplicate(nums):
    seen = set()

    for num in nums:
        if num in seen:
            return True
        seen.add(num)

    return False

print(contains_duplicate([10, 20, 30, 20]))  # True
print(contains_duplicate([1, 2, 3, 4]))      # False
print(contains_duplicate([]))               # False
```

Complexity Check

Fill in the blank:

For the contains_duplicate solution using a set, the expected time complexity is ____.

Test Like Interviewer

Do not stop at the happy path

After coding, test out loud. Use three categories:

  • Normal case: typical input where the answer exists.
  • Edge case: empty list, one item, all same, no match.
  • Tricky case: duplicates late, repeated zeros, negative values, ordering issues.

A good testing sentence sounds like:

“Let me run through a case with a duplicate, one with no duplicate, and an empty input to make sure the return behavior is correct.”

The code below shows a tiny test harness. In a live interview, you might do this mentally or on the whiteboard, but practicing with code builds the habit.

```python
def first_duplicate_trade_id(trade_ids):
    seen = set()

    for trade_id in trade_ids:
        if trade_id in seen:
            return trade_id
        seen.add(trade_id)

    return None

cases = [
    (["T1", "T2", "T3", "T2"], "T2"),
    (["A", "B", "C"], None),
    ([], None),
    (["X", "X"], "X"),
]

for input_ids, expected in cases:
    actual = first_duplicate_trade_id(input_ids)
    print(input_ids, "=>", actual, "expected:", expected, "pass:", actual == expected)
```

When You Get Stuck

Recovery is an interview skill

Getting stuck does not automatically fail the interview. Staying stuck silently is the bigger problem.

Use this recovery script:

  1. Name the obstacle: “I’m not sure how to avoid checking every pair yet.”
  2. Return to examples: “Let me trace a small input.”
  3. Ask what information is repeated: “I need to remember what I have already seen.”
  4. Connect to a known tool: “That suggests a set or dictionary.”
  5. Confirm tradeoff: “This uses extra space to improve time.”

This is where your earlier lessons become a map. If you recognize the shape of the problem, you can search your toolkit instead of panicking.

When You Get Stuck

Post Interview Review

Improvement comes from debriefs

After each mock interview, write a short review. Do this even if the problem felt easy.

Use this template:

  • Problem: What was asked?
  • Pattern: Which earlier lesson did it connect to?
  • Stumble: Where did I slow down?
  • Fix: What will I practice next?
  • One sentence answer: How would I explain the final solution more clearly?

Example:

Problem: first duplicate trade ID.
Pattern: Hashing and Hash Tables.
Stumble: I forgot to clarify return value.
Fix: ask output questions before coding.

Mock interviews are the bridge between knowing data structures and using them under pressure. Next, you will sharpen the way you discuss algorithmic cost even more precisely.

Open interactive view →