@@ -0,0 +1,1145 @@
+class Solution %7B%0A    public int robotSim(int%5B%5D commands, int%5B%5D%5B%5D obstacles) %7B%0A        int%5B%5D dx = new int%5B%5D%7B0, 1, 0, -1%7D;%0A        int%5B%5D dy = new int%5B%5D%7B1, 0, -1, 0%7D;%0A        int x = 0, y = 0, di = 0;%0A%0A        Set%3CLong%3E obstacleSet = new HashSet();%0A        for (int%5B%5D obstacle: obstacles) %7B%0A            long ox = (long) obstacle%5B0%5D + 30000;%0A            long oy = (long) obstacle%5B1%5D + 30000;%0A            obstacleSet.add((ox %3C%3C 16) + oy);%0A        %7D%0A%0A        int ans = 0;%0A        for (int cmd: commands) %7B%0A            if (cmd == -2)  //left%0A                di = (di + 3) %25 4;%0A            else if (cmd == -1)  //right%0A                di = (di + 1) %25 4;%0A            else %7B%0A                for (int k = 0; k %3C cmd; ++k) %7B%0A                    int nx = x + dx%5Bdi%5D;%0A                    int ny = y + dy%5Bdi%5D;%0A                    long code = (((long) nx + 30000) %3C%3C 16) + ((long) ny + 30000);%0A                    if (!obstacleSet.contains(code)) %7B%0A                        x = nx;%0A                        y = ny;%0A                        ans = Math.max(ans, x*x + y*y);%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A%0A        return ans;%0A    %7D%0A%7D

add no.874