1.Restate the problem in your own words
Before writing any code, turn the prompt into a precise contract: exact inputs, exact output, and what happens on ties or missing matches. A vague restatement hides decisions you will otherwise make by accident while coding.
Key features
- A precise restatement names the exact input types, the exact return type, and every edge case
- Writing the restatement as a function signature and docstring forces you to answer questions prose lets you skip
- If two people restate the same prompt differently, the prompt was ambiguous — resolve that before coding, not after
Command
def two_sum_indices(prices: list[int], target: int) -> tuple[int, int] | None:
"""Return the (i, j) indices, i < j, of the first pair of prices
summing to target. Return None if no such pair exists."""Write the restated problem as a function signature and docstring — if you cannot state the exact return type and edge-case behavior, you do not understand the problem yet.