Problem Statement |
| | To obtain the reverse of a number, write it backwards from right to left. For example, the reverse of 1234 is 4321, and the reverse of 100 is 1 (leading zeroes are always ignored). Return the smallest non-negative number x, such that the difference x - reverse(x) is equal to difference. If no such number exists, return "NONE" (quotes for clarity) instead. |
| |
Definition |
| | | Class: | ReverseDistance | | Method: | find | | Parameters: | int | | Returns: | String | | Method signature: | String find(int difference) | | (be sure your method is public) |
|
| |
|
| |
Constraints |
| - | difference will be between 1 and 1000000, inclusive. |
| |
Examples |
| 0) | |
| | | Returns: "20" | 20 - 2 = 18.
18 can be also achieved in other ways like 42 - 24, but 20 is the smallest possible number. |
|
|
| 1) | |
| | | Returns: "NONE" | | It's impossible to find a number with a difference of 15. |
|
|
| 2) | |
| | |
| 3) | |
| | |
| 4) | |
| | |
| 5) | |
| | |
| 6) | |
| | |