dsa · easy
Base 7
Convert the signed integer num to base 7 and return it as a string. Use a leading minus for negatives. Do not emit extra leading zeros (the number 0 is "0").
Arguments
num— signed integer to write in base 7
Example
num = 100. Repeated remainder by 7: 100 = 2*49 + 2, 2 = 0*7 + 2, so the digits from last remainder to first are 2, 0, 2 → "202".
num = -7 → "-10" because 7 = 1*7 + 0.
Constraints
-10^7 <= num <= 10^7
Examples
Example 1
Input: 100 Expected: 202
Example 2
Input: -7 Expected: -10