Class Solution
-
- All Implemented Interfaces:
public final class Solution483 - Smallest Good Base.
Hard
Given an integer
nrepresented as a string, return the smallest good base ofn.We call
k >= 2a good base ofn, if all digits ofnbasekare1's.Example 1:
Input: n = "13"
Output: "3"
Explanation: 13 base 3 is 111.
Example 2:
Input: n = "4681"
Output: "8"
Explanation: 4681 base 8 is 11111.
Example 3:
Input: n = "1000000000000000000"
Output: "999999999999999999"
Explanation: 1000000000000000000 base 999999999999999999 is 11.
Constraints:
nis an integer in the range <code>3, 10<sup>18</sup></code>.ndoes not contain any leading zeros.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final StringsmallestGoodBase(String n)-
-
Method Detail
-
smallestGoodBase
final String smallestGoodBase(String n)
-
-
-
-