Skip to content
Tutorials Center
My learning

Topics

Lesson 85 of 86 ยท Practice and Review

Aptitude Interview Questions

Classic interview puzzles, estimation questions and probability brain teasers with full solutions, code checks and advice on explaining your reasoning.

Some interviews skip the multiple-choice papers and ask a puzzle instead: burn these ropes, weigh these balls, estimate this number. The interviewer rarely cares about the answer itself, which they can look up. They are watching how you think: whether you restate the problem, state assumptions, try small cases, notice when you are stuck, and check your result.

This lesson collects the classic types: logic puzzles with a trick, search puzzles that a program can solve for you, probability brain teasers where intuition fails, and estimation questions. For each one you get the reasoning, and where possible a short program that confirms it. The final section is about communicating, because a correct answer delivered in silence usually scores less than a nearly correct one explained well.

What interviewers are looking for

A good answer has the same skeleton every time, whatever the puzzle:

  1. Restate the problem in your own words and ask about anything unclear (are the ropes uniform? can I weigh more than twice?).
  2. Name your assumptions out loud, so the interviewer can correct them.
  3. Start with a simple or small case, such as two ropes, one ball, or two children, and look for a pattern.
  4. Explore, then commit: try an approach, say why it fails, adjust.
  5. Verify with a quick check or a second method before you announce an answer.

Practice saying all of this aloud; it feels strange at first and becomes natural with a few repetitions.

Puzzle 1: Measure 45 minutes with two ropes

You have two ropes. Each burns for exactly 60 minutes when lit at one end, but they burn unevenly: half the rope's length might take 10 minutes or 50. You have a lighter. Measure exactly 45 minutes.

The key observation is that although you cannot trust lengths, you can trust total burn time: a rope lit at both ends always finishes in 30 minutes, because the two flames together consume the rope in half the time, however unevenly it burns.

  • At time 0, light rope A at both ends and rope B at one end.
  • Rope A burns out at the 30-minute mark. At that moment rope B has exactly 30 minutes of burning left.
  • Light the other end of rope B right then. The remaining 30 minutes of rope now burn from both sides and finish in 15 minutes.
  • Total: 30 + 15 = 45 minutes.

The idea to remember: a flame at each end halves the remaining time. This trick returns in many variants, for example measuring 15 minutes with a single rope.

Puzzle 2: Water jugs

You have a 3-litre jug, a 5-litre jug and a tap, with no markings on either jug. Measure exactly 4 litres.

A classic solution is: fill the 5-litre jug; pour from it into the 3-litre jug (the 5-litre jug now holds 2); empty the 3-litre jug; pour the 2 litres across; fill the 5-litre jug again; top up the 3-litre jug (it needs 1 litre), which leaves 4 litres in the big jug.

This is a search problem: the state is how much water each jug holds, and the moves are fill, empty or pour. A breadth-first search explores states in order of the number of moves, so the first time it reaches 4 litres it has found a shortest solution.

JS Shortest jug solution by search

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The pair in parentheses is (litres in the 3-litre jug, litres in the 5-litre jug). A solution exists here because 3 and 5 share no common factor: with jugs of 4 and 6 litres you could only ever measure even amounts.

Puzzle 3: The heavier ball

Eight balls look identical, but one is slightly heavier. You have a balance scale. Find the heavy ball in two weighings.

The insight is that each weighing has three outcomes (left heavier, right heavier, balanced), so two weighings can separate 3 x 3 = 9 possibilities, enough for eight balls. Divide the balls into groups of 3, 3 and 2.

flowchart TD
    A["Weigh balls 1-3<br/>against balls 4-6"] -->|"left heavier"| B["Heavy ball is in 1-3"]
    A -->|"right heavier"| C["Heavy ball is in 4-6"]
    A -->|"balanced"| D["Heavy ball is 7 or 8"]
    B --> E["Weigh two of them:<br/>heavier side, or the third if balanced"]
    C --> E
    D --> F["Weigh 7 against 8:<br/>the heavier one"]

Splitting 3, 3, 2 lets each weighing use all three outcomes.

A program can test the strategy against every possible position of the heavy ball.

JS Check the 3-3-2 strategy

Press Run (or Ctrl + Enter) to see the console output here.

No output.

(In the group [6, 7] the second weighing compares ball 7 with ball 8; the balanced case never happens there, so group[2] is not needed.) The same thinking tells you that nine balls also need only two weighings (3, 3, 3), and 27 balls need three.

Puzzle 4: Crossing the bridge at night

Four people must cross a narrow bridge at night with one torch. The bridge holds at most two people, and anyone crossing needs the torch. They walk at different speeds: 1, 2, 5 and 10 minutes. A pair walks at the slower person's speed. What is the minimum total time?

The tempting plan is to let the fastest person escort everyone: 2 + 1 + 5 + 1 + 10 = 19 minutes. The better plan sends the two slowest together, so their slowness is paid for once: 1 and 2 cross (2 min), 1 returns (1), 5 and 10 cross (10), 2 returns (2), 1 and 2 cross (2). Total 17 minutes.

The program searches every possible move sequence for the cheapest path, which both confirms the 17 and shows how you could prove it.

JS Bridge crossing by shortest path

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Puzzle 5: Mislabeled boxes and clock hands

Two shorter classics, both solved by finding the one fact that is guaranteed.

Mislabeled boxes. Three boxes are labeled "Apples", "Oranges" and "Apples and Oranges". Every label is wrong. You may take one fruit from one box without looking inside. Which box should you pick from? The "Apples and Oranges" box. Its label is wrong, so it holds only apples or only oranges. Suppose you draw an apple: that box is "Apples". The box labeled "Oranges" cannot be oranges (wrong label) and cannot be apples (taken), so it is the mixed box, and the box labeled "Apples" must be the oranges. Picking from either of the other boxes would leave ambiguity, because they could contain a single fruit or the mix.

Clock hands. How many times do the hour and minute hands of a clock overlap in a day? In 12 hours they overlap 11 times (not 12, because the 12 o'clock overlap at the end of the cycle is the same as the one at the start), so in 24 hours they overlap 22 times. You can derive this from relative speed, as in Clocks: the minute hand gains 330 degrees per hour on the hour hand, so it laps it every 360 / 330 = 12/11 hours.

Probability brain teasers

Probability puzzles are favorites because most people's first instinct is wrong, so the interviewer sees how you react when intuition and calculation disagree. The tools are in Probability and Conditional Probability and Independent Events.

Two children. A family has two children and at least one is a boy. What is the probability that both are boys? The equally likely families are BB, BG, GB, GG. "At least one boy" removes GG, leaving three, and only BB has two boys, so the answer is 1/3, not 1/2. If you were instead told that the elder child is a boy, only BB and BG remain, giving 1/2. The wording of the information changes the answer.

Monty Hall. You choose one of three doors; one hides a prize. The host, who knows where it is, opens a different door with no prize and offers you the chance to switch. Switching wins with probability 2/3. Your first pick was right with probability 1/3, and that does not change when a losing door is opened; the other 2/3 is now concentrated on the one remaining door. Many people refuse to believe this until they simulate it.

Birthday problem. How many people must be in a room for a shared birthday to be more likely than not? The surprising answer is 23. The probability that all n birthdays differ is the product (365/365) x (364/365) x ... x ((365 - n + 1)/365), and one minus this product is the answer. (This assumes 365 equally likely birthdays; real birthdays are slightly uneven, which makes a shared birthday a little more likely.)

JS Two children, Monty Hall and birthdays

Press Run (or Ctrl + Enter) to see the console output here.

No output.

At 23 people the probability is 0.5073, just past one half. At 57 it is already above 99%.

Estimation questions

"How many tennis balls fit in a school bus?" Nobody expects the exact number; they expect a structured guess whose reasoning you can defend. This style is called a Fermi estimate.

flowchart LR
    A["Clarify the question<br/>and the units"] --> B["Break it into parts<br/>you can estimate"]
    B --> C["Estimate each part<br/>with a stated range"]
    C --> D["Multiply, round,<br/>and give a range"]
    D --> E["Sanity check<br/>against something known"]

Break the unknown into small, estimable pieces, then multiply.

For the bus: a bus interior is roughly 10 m long, 2.4 m wide and 2 m high, about 48 cubic metres, of which perhaps 85% is open space once seats are accounted for. A tennis ball has a diameter near 6.7 cm, so a volume of about 0.00016 cubic metres. Balls poured into a space fill about 64% of it. The count is then (open volume x 0.64) / ball volume.

JS Fermi estimate with low and high cases

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The honest answer is "somewhere between 100,000 and 250,000, most likely around 150,000", and that range is itself worth stating. Good habits for any estimate:

  • State each assumption as a number you could be challenged on, so the interviewer can adjust it.
  • Use round figures (10 m, not 9.87 m); false precision signals that you do not understand uncertainty.
  • Errors partly cancel. If you guess some parts high and some low, the product is often closer than you fear. Give a range.
  • Sanity check the result: 150,000 balls at about 57 g each weigh roughly 8.5 tonnes, close to the weight of an empty bus, which tells you the answer is very large but not absurd.

The same method answers market-size questions ("how many pizzas does a city eat per week?"): population, share who eat pizza, times per period, then multiply.

How to explain your reasoning

Practice these habits until they are automatic:

  • Think aloud in short sentences, so silence never lasts more than a few seconds. If you need quiet to calculate, say "let me work this out for 20 seconds".
  • Say where you are stuck. "I'd like to find something guaranteed here" shows judgment; staring does not.
  • Offer a simple case first, even if you will not use it. It buys thinking time and shows structure.
  • Name your answer, then justify it. "I think 17 minutes. Here is why, and here is why I believe nothing faster exists."
  • Accept hints gracefully. An interviewer's hint is information about what they expect, not a penalty. Use it and say so.
  • If you already know the puzzle, say so honestly and offer to explain the solution or a variant. That is worth more than a performance.

Interviewers often follow a solved puzzle with a variant: five people on the bridge, nine balls, three jugs. A solution you understand adapts easily; a memorized one does not. After each puzzle above, ask yourself what would change if one number changed.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Two uneven ropes each burn for exactly 60 minutes. You light rope A at both ends and rope B at one end at the same moment. When rope A has burnt out, you light the other end of rope B. How long after the start does rope B finish?

    Rope A, lit at both ends, finishes at 30 minutes. Rope B then has 30 minutes of burning left, which finishes in 15 minutes once lit from both ends, so B ends at 45 minutes.
  2. 2. A family has two children, and you know that at least one is a boy. Assuming boys and girls are equally likely, what is the probability that both are boys?

    The equally likely families are BB, BG, GB and GG. Knowing that at least one is a boy removes GG, leaving three families, and exactly one of them is BB, so the probability is 1/3.
  3. 3. In the Monty Hall game, you pick a door, the host (who knows where the prize is) opens a different empty door, and offers a switch. What is the probability of winning if you switch?

    Your first pick wins with probability 1/3 and the host's action does not change that. The remaining 2/3 sits on the one unopened door, so switching wins with probability 2/3.
  4. 4. Four people take 1, 2, 5 and 10 minutes to cross a bridge. At most two cross together with a torch, at the slower speed. What is the minimum time for all four to cross?

    Send 1 and 2 across (2), 1 back (1), then 5 and 10 together (10), 2 back (2) and 1 and 2 across (2): 2 + 1 + 10 + 2 + 2 = 17 minutes. Having the fastest escort everyone takes 19.
  5. 5. You estimate the capacity of a room in several steps and your inputs are each uncertain by about a factor of 1.5. What is the best way to present the answer?

    A rounded value with a range shows that you understand the uncertainty in your assumptions. False precision and refusing to estimate are both weaker answers.

Summary

  • Interviewers judge your process: restate, state assumptions, try a small case, commit, verify.
  • A flame at each end halves burning time, and a three-outcome weighing lets two weighings separate nine balls.
  • Search puzzles such as jugs and the bridge are shortest-path problems; a short program can confirm the best answer.
  • Probability teasers (two children, Monty Hall, birthdays) reward careful enumeration over instinct.
  • Estimates need stated assumptions, round numbers, a range and a sanity check; always think aloud and use hints.

Next: Aptitude and Reasoning Cheat Sheet.