2
public int robotSim(int[] commands, int[][] obstacles) {3
int dir = 0; // states 0north-1east-2south-3west9
Set<String> set = new HashSet<>();10
for (int[] obs : obstacles) {11
set.add(obs[0] + "," + obs[1]);16
for (int i : commands) {18
if (i == -1) { // turn right 9020
} else if (i == -2) { // turn left 9022
} else { // move forward value of i baring no obsticals26
} else if (dir == -3) {28
} else if (dir == -2) {36
while (steps < i && !set.contains((xloc) + "," + (yloc + 1))) {40
} else if (dir == 1) {42
while (steps < i && !set.contains((xloc + 1) + "," + (yloc))) {46
} else if (dir == 2) {48
while (steps < i && !set.contains((xloc) + "," + (yloc - 1))) {52
} else { // case dir == 354
while (steps < i && !set.contains((xloc - 1) + "," + (yloc))) {60
farthestSofar = Math.max(farthestSofar, xloc * xloc + yloc * yloc);