2
public List<String> ret;3
public List<String> ans;5
public List<String> ambiguousCoordinates(String s) {6
ret = new ArrayList<>();7
ans = new ArrayList<>();8
String start = s.substring(0, 2);15
void util(String s, int idx) {16
if (idx == s.length() - 2) {20
String ns = s.substring(0, idx + 1) + ", " + s.substring(idx + 1);25
// helper function for puting decimals after comma27
for (String s : ret) {29
for (int i = 0; i < s.length(); i++) {30
if (s.charAt(i) == ',') {35
String a = s.substring(1, cIndex);36
String b = s.substring(cIndex + 2, s.length() - 1);37
List<String> n1 = dot(a);38
List<String> n2 = dot(b);39
if (n1 == null || n2 == null) { // invalid strings41
} else { // valid strings42
for (String fir : n1) {43
for (String sec : n2) {44
ans.add("(" + fir + ", " + sec + ")");51
// putting decimal point52
List<String> dot(String n) {53
List<String> li = new ArrayList<>();54
if (n.length() == 1) {58
// just checking for first and last zeroes and making conditions accordingly60
if (n.charAt(n.length() - 1) == '0') {61
if (n.charAt(0) == '0') {66
} else if (n.charAt(0) == '0') {67
li.add("0." + n.substring(1));69
for (int i = 0; i < n.length() - 1; i++) {70
li.add(n.substring(0, i + 1) + "." + n.substring(i + 1));72
li.add(n); // without any decimal