Tap here to switch tabs
Problem
Submissions

Problem: Ambiguous Coordinates

med
30 min
Try to solve the Ambiguous Coordinates problem.

Statement

Given a string s representing a coordinate pair where all commas, spaces, and decimal points have been removed, return a list of all possible valid original coordinate strings formatted as "(x, y)".

To reconstruct the original coordinate:

  • The digits enclosed inside the parentheses of s must be split into two non empty parts representing x and y.

  • A decimal point may optionally be inserted into x and y.

  • If a decimal point is used, at least 11 digit must precede it and at least 11 digit must follow it.

  • A valid number cannot have unnecessary leading zeroes (for instance, "0", "0.5", and "3" are valid, whereas "00", "01", and "00.5" are invalid).

  • A valid number with a decimal point cannot end with trailing zeroes (for instance, "0.5" and "1.23" are valid, whereas "1.0" and "1.20" are invalid).

The returned list can be in any order.

Constraints:

  • 4≤4 \leq s.length ≤12\leq 12

  • s[0] == '(' and s[s.length - 1] == ')'

  • The rest of s are digits.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Ambiguous Coordinates

med
30 min
Try to solve the Ambiguous Coordinates problem.

Statement

Given a string s representing a coordinate pair where all commas, spaces, and decimal points have been removed, return a list of all possible valid original coordinate strings formatted as "(x, y)".

To reconstruct the original coordinate:

  • The digits enclosed inside the parentheses of s must be split into two non empty parts representing x and y.

  • A decimal point may optionally be inserted into x and y.

  • If a decimal point is used, at least 11 digit must precede it and at least 11 digit must follow it.

  • A valid number cannot have unnecessary leading zeroes (for instance, "0", "0.5", and "3" are valid, whereas "00", "01", and "00.5" are invalid).

  • A valid number with a decimal point cannot end with trailing zeroes (for instance, "0.5" and "1.23" are valid, whereas "1.0" and "1.20" are invalid).

The returned list can be in any order.

Constraints:

  • 4≤4 \leq s.length ≤12\leq 12

  • s[0] == '(' and s[s.length - 1] == ')'

  • The rest of s are digits.