2396. Strictly Palindromic Number Medium
1/**
2 * [2396] Strictly Palindromic Number
3 *
4 * An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.
5 * Given an integer n, return true if n is strictly palindromic and false otherwise.
6 * A string is palindromic if it reads the same forward and backward.
7 *
8 * Example 1:
9 *
10 * Input: n = 9
11 * Output: false
12 * Explanation: In base 2: 9 = 1001 (base 2), which is palindromic.
13 * In base 3: 9 = 100 (base 3), which is not palindromic.
14 * Therefore, 9 is not strictly palindromic so we return false.
15 * Note that in bases 4, 5, 6, and 7, n = 9 is also not palindromic.
16 *
17 * Example 2:
18 *
19 * Input: n = 4
20 * Output: false
21 * Explanation: We only consider base 2: 4 = 100 (base 2), which is not palindromic.
22 * Therefore, we return false.
23 *
24 *
25 * Constraints:
26 *
27 * 4 <= n <= 10^5
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/strictly-palindromic-number/
33// discuss: https://leetcode.com/problems/strictly-palindromic-number/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn is_strictly_palindromic(n: i32) -> bool {
39 false
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_2396() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.