Easy · Math
Convert decimal to base N
Given an integer n and a base between 2 and 16, return n written in that base using the digits 0–9 and A–F, with a leading '-' when n is negative and "0" when n is 0.
Examples
Example 1
{
"n": 45,
"base": 16
}Output: 2D
Example 2
{
"n": 13,
"base": 2
}Output: 1101
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.