3260. Find the Largest Palindrome Divisible by K Hard
1/**
2 * [3260] Find the Largest Palindrome Divisible by K
3 *
4 * You are given two positive integers n and k.
5 * An integer x is called k-palindromic if:
6 *
7 * x is a <span data-keyword="palindrome-integer">palindrome</span>.
8 * x is divisible by k.
9 *
10 * Return the largest integer having n digits (as a string) that is k-palindromic.
11 * Note that the integer must not have leading zeros.
12 *
13 * <strong class="example">Example 1:
14 * <div class="example-block">
15 * Input: <span class="example-io">n = 3, k = 5</span>
16 * Output: <span class="example-io">"595"</span>
17 * Explanation:
18 * 595 is the largest k-palindromic integer with 3 digits.
19 * </div>
20 * <strong class="example">Example 2:
21 * <div class="example-block">
22 * Input: <span class="example-io">n = 1, k = 4</span>
23 * Output: <span class="example-io">"8"</span>
24 * Explanation:
25 * 4 and 8 are the only k-palindromic integers with 1 digit.
26 * </div>
27 * <strong class="example">Example 3:
28 * <div class="example-block">
29 * Input: <span class="example-io">n = 5, k = 6</span>
30 * Output: <span class="example-io">"89898"</span>
31 * </div>
32 *
33 * Constraints:
34 *
35 * 1 <= n <= 10^5
36 * 1 <= k <= 9
37 *
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/find-the-largest-palindrome-divisible-by-k/
42// discuss: https://leetcode.com/problems/find-the-largest-palindrome-divisible-by-k/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47 pub fn largest_palindrome(n: i32, k: i32) -> String {
48 String::new()
49 }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_3260() {
60 }
61}
62
Back
© 2025 bowen.ge All Rights Reserved.