Problem Statement |
| We can rotate a positive integer by removing its leftmost digit and attaching it on the right end. Return the smallest positive value with no leading zeros such that rotating it is the same as multiplying it by p/q. If no such value exists less than 2000000000 (2 billion), return -1. |
|
Definition |
| Class: | FirstToLast | Method: | getSmallest | Parameters: | int, int | Returns: | int | Method signature: | int getSmallest(int p, int q) | (be sure your method is public) |
|
|
|
|
Notes |
- | After rotating, the number may have leading zeros. |
- | Rotating a value less than 10 does not change it. |
|
Constraints |
- | p and q will each be between 1 and 100 inclusive. |
|
Examples |
0) | |
| |
1) | |
| |
2) | |
| |
3) | |
| |
4) | |
| |