Problem
Base36 Square Root
Learn this problemProblem statement
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) → longExamples
Example 1
n = 100return = 14100 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 = 31return = 731 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
nuses only uppercase letters. - The value obtained by interpreting the hexadecimal string of
nas a base-36 number fits in a 64-bit signed integer.