On this page
Before you start
This lesson uses ideas from these earlier lessons. Read them first if any idea is new to you.
01Why interviewers ask this
A problem statement in a coding round is short, often three or four lines. The real problem is longer. The statement hides many rules, and the hidden tests check them. In lesson 7 you saw that clarifying is worth 10 of 100 points. It also protects the 25 points for working code. If you guess a rule wrong, the tests fail, and you only find out at the end.
A weak candidate starts to type at once, or asks 20 questions in a row, or asks what the statement already says. A strong candidate asks 5 to 8 questions, says the assumptions aloud, and writes a numbered list of rules. Then the candidate codes from that list.
At SDE-1 level you should ask about the rules. At SDE-2 level you should also ask about bad input and about what is out of scope. At Senior level you should also name your own assumptions. These cover the size of the data, many callers at the same time, and where the data lives. For each one, propose a default.
02The idea in plain words
Think about ordering a shirt from a tailor. You say: "Make me a shirt." A good tailor does not start to cut. The tailor asks about the size, the collar, the colour and the date, and writes it all on a slip. Later, when you say "that is not what I asked", the slip shows who is right.
The problem statement is your "make me a shirt" sentence. A clarifying question is a question that makes one hidden rule visible. A rules list is the slip: a short numbered list of what the code must do, with one example for each rule. In lesson 3 you learned to ask for requirements before a design. This is the same habit for code, with smaller questions.
Seven groups of questions
Use these seven groups as a checklist. You do not ask all of them every time. The examples come from a problem we use below: coupon codes for a food-ordering app.
- Who uses it and what do they do. "Does one order use one code, or can it use two?"
- Rules and numbers. Limits, prices, rounding and ties. A tie is two values that are equal, so the rule cannot pick one. A cap is the most that something can be, for example a discount of at most Rs 50. "Is the discount a percent or a fixed amount? Is there a cap? Do we round the discount up or down?"
- Bad input. A bad input is a value the code should not accept, such as a code that does not exist. "What do I return? Does anything change when the input is bad?"
- Time, ids and order. "How does today's date reach the code? What do the ids look like? Is the order shown as text order or number order?" Text order puts
C10beforeC9, because the text1comes before9. - Size and many callers. "How many items? Does one caller use the code, or many at the same time? Is everything kept in memory only?"
- Scope. What is out of scope: left out on purpose. "Do I build payment, saving data on disk, or a screen?" The answer is usually no. Ask so that you do not build it.
- A sample run. "Can you give me one example with real numbers?" It tells you the format of the input and of the answer.
Say an assumption aloud
Sometimes the interviewer says: "Your choice." Do not guess in silence. An assumption is an answer that you choose and say aloud because you do not know the real one. Use one fixed sentence: "I assume X. Tell me if not." The interviewer can agree in two seconds or correct you. Both are good for you.
Words that hide rules
Some words in a statement look clear but hide a rule. Mark them and ask.
| Word in the statement | The question it hides |
|---|---|
| nearest | Nearest by what? What if two are equally near? |
| first | First by time, by id or by name? |
| free | Free for everyone, or only above an amount? |
| limit | Is a value equal to the limit allowed? |
| latest | Latest by which time? What if two have the same time? |
| at least | Does the value itself count? |
Look at every boundary. A boundary is the exact number where a rule changes. Take "at least Rs 500". Ask about the three cases: below 500, exactly 500, and above 500. The middle case is the one that people forget.
Turn the answers into a rules list
When you can write 3 sample calls, stop asking. Then write the rules list:
- Number every rule. The numbers let you say "rule 4" during the round.
- Write one rule in one sentence.
- Put one small example next to every rule that has a number in it.
- Write the assumptions in the list too, marked with the word "assume".
- Write the answers down. Do not keep them in your head, because you will need them again later in the round.
Take 5 to 10 minutes in total. In the practice round of lesson 7 the limit for the whole clarify step is 10 minutes. Five to eight questions fit in that time.
Want to check your understanding? Try explaining this idea in your own words. You can continue reading first, or ask the AI tutor a question. Sign up free to ask the tutor
03Pause and predict
Pause. Guess first.
A statement says: "A coupon works when the order is at least Rs 500." An order is exactly Rs 500. Which group of questions does your question belong to, and what do you write in your rules list?
Write your guess before you read on. The answer is in the worked example.
04Worked example
The statement is: "Build coupon codes for a food-ordering app. A customer applies a code to an order and gets a lower total." That is all. Here are eight questions and the answers an interviewer gives.
| # | Group | Question | Answer |
|---|---|---|---|
| 1 | Users | One code or many for each order? | One code for each order. |
| 2 | Rules and numbers | What kinds of code are there? | Percent codes, with a cap on the discount. Flat codes, with a fixed amount off. |
| 3 | Rules and numbers | Is there a minimum order? Does the minimum itself count? How do we round a percent discount? | Each code has a minimum, and an order equal to it works. Round down to a whole rupee. |
| 4 | Time, ids and order | How long is a code valid, and how does the date arrive? | Until the end of its last day. Each call carries the date as text, like 2026-11-10. |
| 5 | Rules and numbers | How many times can a customer use a code? | Once for each customer. |
| 6 | Bad input | What if the code is unknown, expired, too small an order, or already used? | Refuse with a reason. Nothing changes when refused. |
| 7 | Size and many callers | How many codes? How many callers? | Up to 1,000 codes. One caller at a time. Memory only. |
| 8 | Scope | Do we build payment, saving data on disk, or a screen? | No. Only the code that works out the new total. |
Question 4 hides a point about order. The date 2026-11-10 is year, month, day. Text of this shape sorts correctly as text, because the biggest part comes first. The date 10-11-2026 would not. Question 3 matters too. Ten percent of Rs 205 is 20.5, and the answer says 20.
The rules list. Assumption: two codes exist.
SAVE10: 10 percent off, cap Rs 50, minimum Rs 200, valid till2026-11-30.FLAT100: Rs 100 off, minimum Rs 500, valid till2026-11-20.
The rules are:
- A code is percent or flat. Percent discount = order total x percent / 100, rounded down, and at most the cap. Flat discount = the fixed amount. Example:
SAVE10on Rs 560 gives 560 x 10 / 100 = 56, the cap is 50, so the discount is Rs 50. - The order total must be at least the minimum. A total equal to the minimum works. Example:
FLAT100on Rs 499 is refused, on Rs 500 it gives Rs 400. - A code works up to and including its last day. Example:
SAVE10works on2026-11-30and is refused on2026-12-01. - A customer can use a code once. A refused call does not count as a use. Example: a second
SAVE10call byu1is refused. - One code for each order. Example:
SAVE10andFLAT100on the same order is not allowed. - Unknown code, expired code, small order, used code: refuse with a reason, and change nothing. Example:
NEWYEARis refused as unknown. - Everything stays in memory, with one caller at a time. Assume: amounts are whole rupees, and the new total is never below 0. Example:
SAVE10on Rs 205 gives 205 x 10 / 100 = 20.5, rounded down to 20, so the total is Rs 185.
Three sample calls. These lines are plain text, not code to run.
apply("SAVE10", "u1", 560, "2026-11-10") -> 510
apply("SAVE10", "u1", 560, "2026-11-10") -> refused: already used
apply("FLAT100", "u2", 499, "2026-11-10") -> refused: below the minimum of 500The calculation for call 1. Ten percent of Rs 560 is 560 x 10 / 100 = Rs 56. The cap is Rs 50, so the discount is the smaller number, Rs 50. The new total is 560 - 50 = Rs 510.
The predict box. "At least Rs 500" is a boundary, so you ask a question from the group "rules and numbers": "Does Rs 500 itself count?" The interviewer said yes in question 3. Your list says so in rule 2, with an example. FLAT100 on Rs 499 is refused. On Rs 500 it gives 500 - 100 = Rs 400. On Rs 501 it gives Rs 401. If the interviewer had said "your choice", you would say: "I assume Rs 500 counts. Tell me if not."
You asked 8 questions, wrote 7 rules and 3 sample calls. Assumption: each question and answer takes about 40 seconds. Then the questions take 8 x 40 = 320 seconds, which is about 5 minutes. That leaves 10 - 5 = 5 minutes to write the list and the sample calls.
05Trade-offs
Asking first solves the risk of building the wrong rules. It costs minutes that you could use for code. If you ask too many questions, or ask what the statement already says, the interviewer may think you cannot decide. I would shorten the questions when the round is short, say the assumptions aloud in one sentence each, and start coding sooner. I would ask more when the statement is vague and the cost of a wrong guess is a rewrite.
06Common misconceptions
"The statement is complete, so a question looks weak." The statement is short on purpose. Interviewers expect questions, and Tradeoff gives 10 points for them. A question that shows a hidden rule (the boundary, the rounding) looks strong.
"The more questions I ask, the better." Twenty questions use half the clarify time and show that you cannot decide. Ask 5 to 8, and for the rest say an assumption.
"An assumption is a guess, so it is risky." A silent guess is risky. A spoken assumption is safe: the interviewer can correct it at once, and it goes into your rules list.
07How to say it in the interview
Say it like this
Before I design anything, I ask a few questions about the rules, bad input and what is out of scope. When a choice is mine, I say "I assume X, tell me if not", and I write every rule in a numbered list.
08Check your understanding
- Name the seven groups of questions.
- Using the rules list above, a customer applies
SAVE10to an order of Rs 205 on2026-11-10. What is the new total? Show the discount step by step. - A statement says: "Give the nearest driver a free ride if the trip is at least 5 km." You have two minutes. Which words hide rules, and what do you ask or assume?
09Answers
Show the answers
- Who uses it and what they do; rules and numbers; bad input; time, ids and order; size and many callers; scope; a sample run.
- The minimum of
SAVE10is Rs 200, and 205 is above it. The discount is 205 x 10 / 100 = 20.5, rounded down to Rs 20. This is below the cap of Rs 50. The new total is 205 - 20 = Rs 185. - Three words hide rules. "Nearest" hides "nearest to what, and what if two drivers are equally near?" "Free" hides "free for everyone, or only for the first ride?" "At least" hides "does a trip of exactly 5 km count?" Ask the first two. Assume the third. For the tie, you can say: "I assume the driver with the smaller id wins a tie. Tell me if not." Write all the answers in the rules list.
10Summary card: clarifying a coding problem
One-page summary
- Idea. The statement hides rules. Ask first, say assumptions aloud, write a numbered rules list.
- Seven groups. Users, rules and numbers, bad input, time and ids and order, size and many callers, scope, a sample run.
- Numbers. 5 to 8 questions. 5 to 10 minutes. Stop when you can write 3 sample calls. Clarifying is 10 of 100 points.
- Phrase. "I assume X. Tell me if not."
- Hidden-rule words. nearest, first, free, limit, latest, at least. Check below, at, and above every boundary.
- Trade-off. It solves wrong rules. It costs minutes. Ask less in a short round.
- Trap. Coding at once, or asking 20 questions, or not writing the answers down.
11Sources
- The clarify step, its 10-minute limit and the weight of 10 out of 100 points come from the Tradeoff machine-coding practice round (
docs/specs/machine-coding-round.md). Lesson 7 uses the same source. Other companies use other rules. - The coupon codes, the prices and the dates are made up for teaching. The sample calls and the numbers in the rules were checked with a short Python program.
Try what you just learned
Put this idea into practice with a short exercise or a relevant tool. Free to try. No sign-up needed.
More practice. This needs a free account.
What to learn next
Continue learning with the lessons that build on this one.
- Encapsulation: keep the data safe inside the class
- Interfaces and polymorphism: one call, many behaviours
- Composition or inheritance: has-a or is-a
Practise this idea
Have a question about this lesson?
Ask the AI tutor to explain a difficult idea, walk through an example or check your understanding. It uses the lesson to help you work through the topic.
A free account includes 10 AI tutor questions a day. The lesson remains free to read without an account.
All lessons in Module 2: Low-level design and machine coding
Prefer another topic? Browse all 169 lessons.