Decision: Which contributions determine the suffix without constructing the factorial, and why does merely counting multiples of five miss one?
1 / 9
Palindrome Number — predict before coding
Reverse only the suffix until it meets the remaining prefix. This compares decimal structure without constructing the entire reversed integer, whose value might overflow.
Decision: Adapt the half-reversal reasoning to a binary representation with no leading zeroes. Which division, remainder, and middle-bit operations replace the decimal ones? Check binary 1001 and 110.
2 / 9
Plus One — predict before coding
The only digits that propagate an increment are a suffix of nines. Once one non-nine absorbs the carry, every earlier digit is already correct.
Decision: A caller keeps digits=[9], calls PlusOne(digits) but ignores its returned slice, then calls PlusOne(digits) again. What does the caller’s original slice contain after each call, and why does this not represent two increments of 9?
3 / 9
Factorial Trailing Zeroes — predict before coding
Every trailing decimal zero comes from a factor 10=2*5. Factorials supply more twos than fives, so count the exponent of five without constructing the factorial.
Decision: Suppose you already know the trailing-zero count of 99!. How much does it increase at 100!, and how much at 101!? Derive the change from the new multiplier instead of recomputing the whole factorial.
4 / 9
Sqrt(x) — predict before coding
The predicate mid²<=x changes from true to false over nonnegative mid. Find its last true value, retaining a feasible answer while narrowing the remaining search.
Decision: A learner returns immediately at the first midpoint satisfying mid²<=x. With the stated interval [0,x] and x=35, trace until that first feasible midpoint. Is it the required answer?
5 / 9
Pow(x, n) — predict before coding
Write the exponent in binary. Squaring moves to the next power-of-two contribution, and an odd low bit says to multiply that contribution into the result.
Decision: A refactor squares the current base before checking the exponent’s low bit. Give the smallest positive exponent that exposes the change, using base 3. Which identity did the reordered update fail to preserve?
6 / 9
Max Points on a Line — predict before coding
Anchor one point and group other points by an exact normalized direction. Rational slope keys avoid floating equality errors, and duplicate coordinates must be counted separately from direction.
Decision: An anchor is (0,0), with other points (1,1), (-1,-1), and (-1,1). A key built from (abs(dx),abs(dy)) puts all three in one bucket. Which points actually share a line, and how should sign normalization differ?
7 / 9
Change the output base
How many trailing zeroes does 10! have in base 12?
Factor the base, derive the limiting contribution, and explain why counting fives would be wrong.
8 / 9
Reconstruct and transfer
For each technique, name the representation and its numeric bounds.
Distinguish exact integer logic, floating-point approximation, and preserved mutation.
9 / 9
←/→ or click edges to navigate · ? help · N notes · F fullscreen