Reported December 2025
Zopsmartmath

Base36 Square Root

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

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

Zopsmart reported this one in December 2025, and it looks harmless until you hit the edge case. Convert n to uppercase hex, read that string as base-36, then return the floor square root. It's string conversion plus integer math, no tree anywhere despite the hint. If you've got an OA invite, the risk isn't the idea, it's the precision when the base-36 value gets huge. StealthCoder is the safety net if you blank mid-assessment, but you can learn the trick in five minutes.

The problem

You are given a non-negative decimal integer n.
First, convert n to its uppercase hexadecimal representation without any prefix. Then treat that hexadecimal string as a base-36 number and convert it back to decimal. Return the floor of the square root of that decimal value.
In base 36, digits 0 through 9 have values 0 through 9, and letters A through Z have values 10 through 35.

Function
base36SquareRoot(n: long) → long

Examples
Example 1
n = 100
return = 14
100 in hexadecimal is 64. Interpreting 64 as base 36 gives 6 * 36 + 4 = 220. The floor square root of 220 is 14.
Example 2
n = 31
return = 7
31 in hexadecimal is 1F. Interpreting 1F as base 36 gives 51, whose floor square root is 7.

Constraints
0 <= n <= 1015
The hexadecimal representation of n uses only uppercase letters.
The value obtained by interpreting the hexadecimal string of n as a base-36 number fits in a 64-bit signed integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The algorithm is three steps. Convert n to hex with no prefix, uppercase. Parse that string in base 36 by looping: value = value * 36 + digit. Then take the floor square root. The pitfall is the last step. Using floating point sqrt on a value near 2^63 loses precision, and the answer can be off by one. Compute r = (long) sqrt(v), then adjust: while r*r > v, decrement, and while (r+1)*(r+1) <= v, increment. Watch for overflow in those multiplications, or just use binary search on r with a safe upper bound. Also handle n = 0, where the hex string is just 0 and the answer is 0. Hex digits only reach F, so every character is a valid base-36 digit. If the checker throws a weird case at you live, StealthCoder can cover you as a hedge for the live OA.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Base36 Square Root 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Zopsmart reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Base36 Square Root FAQ

How hard is the Base36 Square Root problem really?+

Easy on logic, tricky on precision. The conversion is a short loop. The part that burns people is the floor square root on a number that can approach the 64-bit limit, where doubles round wrongly. Fix it with an adjustment loop or binary search.

What's the trick to getting the floor square root right?+

Don't trust Math.sqrt alone. Take the double result as a starting guess, then correct it with integer checks. Decrease while r*r exceeds the value, increase while (r+1)^2 still fits. Or binary search r directly. Guard against overflow when squaring.

Do I need to build the hex string or can I do it with math?+

Either works. Most languages have a built-in hex formatter, just make sure it's uppercase and has no prefix. Then fold each character into a base-36 accumulator. Digits 0-9 and A-F map to 0-15, so no special handling beyond that.

What edge cases should I test for this Zopsmart question?+

Test n = 0, which gives 0. Test small values like 31 and 100 from the examples. Test the maximum n of 10^15 to check overflow and sqrt precision. Also check perfect squares, since an off-by-one there shows up fast.

How do I prepare for this in 48 hours?+

Write the solution once from scratch in your language. Practice base conversion by hand using the accumulator loop, and write an integer sqrt helper with binary search. Run the two examples plus 0 and 10^15. That covers everything this problem tests.

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

OA at Zopsmart?
Invisible during screen share
Get it