3704. Count No-Zero Pairs That Sum to N Hard
1/**
2 * [3704] Count No-Zero Pairs That Sum to N
3 *
4 * A no-zero integer is a positive integer that does not contain the digit 0 in its decimal representation.
5 * Given an integer n, count the number of pairs (a, b) where:
6 *
7 * a and b are no-zero integers.
8 * a + b = n
9 *
10 * Return an integer denoting the number of such pairs.
11 *
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">n = 2</span>
15 * Output: <span class="example-io">1</span>
16 * Explanation:
17 * The only pair is (1, 1).
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">n = 3</span>
22 * Output: <span class="example-io">2</span>
23 * Explanation:
24 * The pairs are (1, 2) and (2, 1).
25 * </div>
26 * <strong class="example">Example 3:
27 * <div class="example-block">
28 * Input: <span class="example-io">n = 11</span>
29 * Output: <span class="example-io">8</span>
30 * Explanation:
31 * The pairs are (2, 9), (3, 8), (4, 7), (5, 6), (6, 5), (7, 4), (8, 3), and (9, 2). Note that (1, 10) and (10, 1) do not satisfy the conditions because 10 contains 0 in its decimal representation.
32 * </div>
33 *
34 * Constraints:
35 *
36 * 2 <= n <= 10^15
37 *
38 */
39pub struct Solution {}
40
41// problem: https://leetcode.com/problems/count-no-zero-pairs-that-sum-to-n/
42// discuss: https://leetcode.com/problems/count-no-zero-pairs-that-sum-to-n/discuss/?currentPage=1&orderBy=most_votes&query=
43
44// submission codes start here
45
46impl Solution {
47 pub fn count_no_zero_pairs(n: i64) -> i64 {
48
49 }
50}
51
52// submission codes end
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn test_3704() {
60 }
61}
62Back
© 2026 bowen.ge All Rights Reserved.