2. Determine all natural numbers $n$ such that each of the digits $0,1,2, \ldots$, 9, appears exactly once in the representations of the numbers $n^{3}$ or $n^{4}$, but not in both numbers simultaneously.

Example. If only the digits $1,2,7$ and 8 need to be used, then the number 3 is a solution. Each of the digits $1,2,7$ and 8 appears exactly once in $3^{3}=27$ or in $3^{4}=81$, but not in both numbers simultaneously.
Solution. If $n$ is a one-digit number, then $n^{3} \leq 9^{3}=729$ and $n^{4} \leq 9^{4}=6561$, meaning that at most 7 digits are needed to write the numbers $n^{3}$ and $n^{4}$. If $n$ has more than two digits, then $n^{3} \geq 100^{3}=10^{6}$ and $n^{4} \geq 100^{4}=10^{8}$, so at least 16 digits are needed to write the numbers $n^{3}$ and $n^{4}$. Therefore, $n$ is a two-digit number, and $n^{3}$ is at least a four-digit number, while $n^{4}$ is at least a five-digit number. We can conclude that $n^{3}$ must be a four-digit number, and $n^{4}$ must be a six-digit number (both numbers cannot be five-digit numbers when $n$ is a two-digit number). Then $1000 \leq n^{3} \leq 9999$, from which $10 \leq n \leq 21$, and from $100000 \leq n^{4} \leq 999999$, we have that $18 \leq n \leq 31$. This means that $n \in \{18,19,20,21\}$. Since both $20^{3}$ and $20^{4}$ end in 0, and both $21^{3}$ and $21^{4}$ end in 1, in these cases, there is a repetition of digits in the representations of the numbers, so the numbers 20 and 21 are not solutions to the problem. In the representation of the number $19^{4}=130321$, there is a repetition of digits, so the number 19 is not a solution to the problem. Since $18^{3}=5832$ and $18^{4}=104976$, the only number that satisfies the required property is the number 18.