We want to solve the equation $k + S(k) = 10^n$ for some natural number $n \in \mathbb{N}$. First observe that:
- if $k$ has more than $n$ significant digits, then $k \geq 10^n$ and $S(k) \geq 1$ so $k + S(k) \geq 10^n + 1$ hence $k + S(k) \ne 10^n$.
- if $k$ has less than $n$ significant digits, then $k < 10^{n - 1}$ and $S(k) \leq 9(n - 1)$ so $k + S(k) < 10^{n - 1} + 9(n - 1) < 10^n$.
Therefore if $k$ is a solution then $k$ has exactly $n$ significant digits. Therefore write:
$$k = s_{n - 1} \cdot 10^{n - 1} + s_{n - 2} \cdot 10^{n - 2} + \cdots + s_1 \cdot 10 + s_0 = \sum_{i = 0}^{n - 1} s_i \cdot 10^i$$
For $0 \leq s_0, s_1, \cdots, s_{n - 1} \leq 9$, and also notice that:
$$10^n = 9 \cdot 10^{n - 1} + 9 \cdot 10^{n - 2} + \cdots + 9 \cdot 10 + 9 + 1 = 1 + \sum_{i = 0}^{n - 1} 9 \cdot 10^i$$
Therefore we must have:
$$S(k) = 10^n - k = 1 + \left [ \sum_{i = 0}^{n - 1} 9 \cdot 10^i \right ] - \left [ \sum_{i = 0}^{n - 1} s_i \cdot 10^i \right ] = 1 + \sum_{i = 0}^{n - 1} \left ( 9 \cdot 10^i - s_i \cdot 10^i \right ) = 1 + \sum_{i = 0}^{n - 1} \left ( 9 - s_i \right ) \cdot 10^i$$
And since $S(k)$ is just the sum of the digits $s_0, s_1, \cdots, s_{n - 1}$ this simplifies to:
$$\sum_{i = 0}^{n - 1} s_i = 1 + \sum_{i = 0}^{n - 1} \left ( 9 - s_i \right ) \cdot 10^i$$
Now suppose that $n = 6$ as in the first part of the problem. Then we know that $S(k) \leq 6 \cdot 9 < 100$, and so it's clear that all $s_i$'s but the least two significant $s_1$ and $s_0$ must be equal to $9$ since otherwise the sum contains a term greater than $10^2$ and so the equality cannot hold. Therefore we have $s_5 = s_4 = s_3 = s_2 = 9$ and therefore the equation becomes:
$$9 \cdot 4 + s_1 + s_0 = 1 + 10(9 - s_1) + (9 - s_0) ~ ~ ~ \iff ~ ~ ~ 11 s_1 + 2 s_0 = 64 ~ ~ ~ \iff ~ ~ ~ s_0 = 32 - \frac{11}{2} s_1$$
So $s_1$ has to be even, and enumerating all possible values $s_1 = 2, 4, 6, 8$ shows that the equation above admits no integer solutions in $(s_0, s_1)$. Therefore are no solutions to the problem for $n = 6$ and so $k + S(k) = 10^6$ has no solutions.
Now suppose that $n = 9$ as in the second part of the problem. We have $S(k) \leq 9 \cdot 9 < 100$ so it still holds that all but the least two significant digits are equal to $9$, and so the equation in this case is:
$$9 \cdot 7 + s_1 + s_0 = 1 + 10(9 - s_1) + (9 - s_0) ~ ~ ~ \iff ~ ~ ~ 11 s_1 + 2 s_0 = 37 ~ ~ ~ \iff ~ ~ ~ s_0 = \frac{37 - 11 s_1}{2}$$
And we see that $s_1$ has to be odd, and checking all possible values $s_1 = 1, 3, 5, 7, 9$ we find the unique solution $(s_0, s_1) = (2, 3)$, giving the unique solution to the problem for $n = 9$ given by $s_8 = s_7 = s_6 = s_5 = s_4 = s_3 = s_2 = 9$, $s_1 = 3$, $s_0 = 2$, that is, $k = 999999932$. And indeed:
$$999999932 + S(999999932) = 999999932 + 68 = 10^9$$
$\blacksquare$