Reported September 2026
Reductomath

Recover Document Hierarchy from Indentation

Reported by candidates from Reducto's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Reducto OA. Under 2s to a working solution.
Founder's read

The Reducto OA reported in September 2026 looks like a document-parsing puzzle, but there's no tree to build. It's a rounding problem wrapped in a string format. You get text objects in reading order, a left distance for each, and a base unit. The only data structure you need is an array you walk once. Divide left by baseUnit, round to the nearest integer, and print level|text. If you blank on the floating-point part, StealthCoder runs invisibly during the live assessment and can hand you the clean version. Most of the difficulty is trusting that the problem is this simple.

The problem

A document parser returns text objects in reading order. texts[i] is the object's text, and distances[i] is [left, top, right, bottom], its distances from the four page borders.
The left distance encodes indentation. A positive baseUnit is one indentation level, and every quotient distances[i][0] / baseUnit is within 0.01 of one unique nonnegative integer.
Return one string per object, preserving reading order, in the form level|text. The level is that unique integer. The other three border distances do not affect it.

Function
recoverIndentation(texts: String[], distances: double[][], baseUnit: double) → String[]

Examples
Example 1
texts = ["Title","Section","Paragraph","Note"]
distances = [[0,0,8,1],[2.01,1,5.99,1],[4,2,4,1],[6.02,3,1.98,1]]
baseUnit = 2
return = ["0|Title","1|Section","2|Paragraph","3|Note"]
Each left distance is within one hundredth of a multiple of 2, so the levels are 0 through 3.
Example 2
texts = ["Heading","Indented","Back"]
distances = [[0,7,9,2],[2.49,0,1,3],[1.26,8,4,0]]
baseUnit = 1.25
return = ["0|Heading","2|Indented","1|Back"]
The levels follow left distance only and preserve input order; they do not need to be monotone.

Constraints
1 <= texts.length == distances.length <= 100000.
Each text has length from 1 through 100.
Every distance row is [left, top, right, bottom].
All distances are finite values from 0 through 1000000 with at most two decimal places.
0.01 <= baseUnit <= 1000000 and it has at most two decimal places.
Every left / baseUnit quotient is within 0.01 of one unique nonnegative integer no greater than 1000000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is Math.round(left / baseUnit). The statement guarantees every quotient sits within 0.01 of one unique nonnegative integer, so rounding always lands on the right level. Don't floor or truncate. Example 1 has 2.01 / 2 = 1.005, and 5.99 would break a floor. Example 2 has 2.49 / 1.25 = 1.992, which floors to 1 but should be 2. Ignore top, right and bottom completely, they're distractors. Keep input order, don't sort, and don't expect levels to be monotone. Build each output as level + '|' + text. Use a StringBuilder or array join for 100000 rows, and watch that the level prints as an integer, not 2.0. This is a single O(n) pass. StealthCoder is your hedge if the rounding and formatting details slip under OA pressure.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Recover Document Hierarchy from Indentation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder
⏵ The honest play

You've seen the question. Make sure you actually pass Reducto's OA.

Reducto reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Recover Document Hierarchy from Indentation FAQ

How hard is the Reducto indentation problem really?+

Easy. It's one pass with a division and a round. The only way to lose it is using floor or truncation, or overthinking it into a stack or tree. Read the guarantee about the 0.01 tolerance and the solution falls out.

What's the trick to recoverIndentation?+

Round left / baseUnit to the nearest integer. The constraints promise each quotient is within 0.01 of exactly one integer, so rounding is always safe. Then format as level|text and keep the original order.

Why not use floor instead of round?+

Floating-point and the 0.01 tolerance push values slightly below the true integer. 2.49 / 1.25 is 1.992, so floor gives 1 instead of 2. Rounding fixes it. Always round for this kind of noisy measured input.

Do the top, right and bottom distances matter?+

No. The statement says they don't affect the level. Only distances[i][0] is used. Ignore the rest, and don't sort or group by them, since output must preserve reading order.

How do I prepare for this in 48 hours?+

Practice small string-formatting and rounding problems, and check edge cases: left of 0, a tiny baseUnit like 0.01, and large inputs near 1000000. Make sure your output prints integers and your code runs in linear time for 100000 rows.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Reducto.

OA at Reducto?
Invisible during screen share
Get it