483. Smallest Good Base Hard

@problem@discussion
#Math#Binary Search



1/**
2 * [483] Smallest Good Base
3 *
4 * Given an integer n represented as a string, return the smallest good base of n.
5 * We call k >= 2 a good base of n, if all digits of n base k are 1's.
6 *  
7 * Example 1:
8 * 
9 * Input: n = "13"
10 * Output: "3"
11 * Explanation: 13 base 3 is 111.
12 * 
13 * Example 2:
14 * 
15 * Input: n = "4681"
16 * Output: "8"
17 * Explanation: 4681 base 8 is 11111.
18 * 
19 * Example 3:
20 * 
21 * Input: n = "1000000000000000000"
22 * Output: "999999999999999999"
23 * Explanation: 1000000000000000000 base 999999999999999999 is 11.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	n is an integer in the range [3, 10^18].
29 * 	n does not contain any leading zeros.
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/smallest-good-base/
35// discuss: https://leetcode.com/problems/smallest-good-base/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn smallest_good_base(n: String) -> String {
41        String::new()
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_483() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.