Imagine you're a forensic data analyst tasked with reconstructing corrupted GPS coordinates! You have a string that represents coordinates where all formatting has been stripped away - no commas, decimal points, or spaces remain.
Your mission: determine all possible valid coordinate pairs that could have produced this string.
The Challenge: Given a string like "(205)", figure out if it could represent coordinates like "(2, 0.5)", "(20, 5)", or "(2.0, 5)".
Important Rules:
- ๐ซ No leading zeros in integers (avoid "001", "00.5")
- ๐ซ No trailing zeros in decimals (avoid "1.0", "2.50")
- ๐ซ No decimals starting with a point (avoid ".5")
- โ Each coordinate must have exactly one space after the comma
Goal: Return a list of all possible valid coordinate representations that could have produced the input string.
Input & Output
Visualization
Time & Space Complexity
For each of n possible splits, we try O(n) decimal positions for each part, and O(n) validation time
Storing all possible valid coordinate combinations
Constraints
- 4 โค s.length โค 12
- s[0] == '(' and s[s.length - 1] == ')'
- The rest of s are digits
- No extraneous leading zeros in original coordinates
- No trailing zeros in decimal representations