返回介绍

solution / 2300-2399 / 2396.Strictly Palindromic Number / README_EN

发布于 2024-06-17 01:03:06 字数 2693 浏览 0 评论 0 收藏 0

2396. Strictly Palindromic Number

中文文档

Description

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.

Given an integer n, return true _if _n_ is strictly palindromic and _false_ otherwise_.

A string is palindromic if it reads the same forward and backward.

 

Example 1:

Input: n = 9
Output: false
Explanation: In base 2: 9 = 1001 (base 2), which is palindromic.
In base 3: 9 = 100 (base 3), which is not palindromic.
Therefore, 9 is not strictly palindromic so we return false.
Note that in bases 4, 5, 6, and 7, n = 9 is also not palindromic.

Example 2:

Input: n = 4
Output: false
Explanation: We only consider base 2: 4 = 100 (base 2), which is not palindromic.
Therefore, we return false.

 

Constraints:

  • 4 <= n <= 105

Solutions

Solution 1

class Solution:
  def isStrictlyPalindromic(self, n: int) -> bool:
    return False
class Solution {
  public boolean isStrictlyPalindromic(int n) {
    return false;
  }
}
class Solution {
public:
  bool isStrictlyPalindromic(int n) {
    return false;
  }
};
func isStrictlyPalindromic(n int) bool {
  return false
}
function isStrictlyPalindromic(n: number): boolean {
  return false;
}
impl Solution {
  pub fn is_strictly_palindromic(n: i32) -> bool {
    false
  }
}
bool isStrictlyPalindromic(int n) {
  return 0;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文