816. Ambiguous Coordinates
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def ambiguousCoordinates(self, s: str) -> list[str]:
        def valid_parts(s):
            n = len(s)
            if n == 0 or (n > 1 and s[0] == '0' and s[-1] == '0'):
                return []
            if n > 1 and s[0] == '0':
                return [f"0.{s[1:]}"]
            res = [s]
            for i in range(1, n):
                if s[-1] != '0':
                    res.append(f"{s[:i]}.{s[i:]}")
            return res

        def make_coordinates(s):
            n = len(s)
            results = []
            for i in range(1, n):
                left = valid_parts(s[:i])
                right = valid_parts(s[i:])
                for l in left:
                    for r in right:
                        results.append(f"({l}, {r})")
            return results

        s = s[1:-1]
        return make_coordinates(s)

```
['Python3']