A developer tool converts IDs between bases. digits is a non-negative number written in base fromBase, using 0-9 then a-z (upper case letters mean the same as lower case). It may have leading zeros and may be far larger than 2^53.
Write rebase(digits, fromBase, toBase) that returns the same number written in base toBase, using lowercase letters and no leading zeros (zero is "0").
Input: digits = "ff", fromBase = 16, toBase = 2 Output: "11111111"
ff is 255, which is eight 1s in binary.
Input: digits = "101", fromBase = 2, toBase = 10 Output: "5"
1 × 4 + 0 × 2 + 1 = 5.
2 <= fromBase, toBase <= 361 <= digits.length <= 100fromBase.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #655 Rebase a Number String. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.