Intuition
- Use a map to save the fractional index of each meet numerator.
- When the map contains a numerator, so it’s a repeating fractional, the range is from the value of key to the current.
- When the numerator can be divided at some point, so it’s not a repeating fractional, just return the string.
solution
|
|
problem
WA.
reason
Miss the negative numbers.
modification
|
|
problem
WA.
Input:
-1
-2147483648
Output:
“-0.0000000000000000000000000000001”
Expected:
“0.0000000004656612873077392578125”
reason
Precision.
modification
Use Long instead of int
|
|