fork download
  1. public class RobotOnMoon
  2. {
  3. public int LongestSafeCommand(String[] board)
  4. {
  5. int n = board.length, m = board[0].length();
  6. int x = 0, y = 0;
  7. for(int i = 0; i < n; i++)
  8. for(int j = 0; j < m; j++)
  9. if(board[i].charAt(j) == 'S')
  10. {
  11. x = i;
  12. y = j;
  13. }
  14. for(int i = 0; i < n; i++)
  15. for(int j = 0; j < m; j++)
  16. if(board[i].charAt(j) == '#' && (i == x || j == y))
  17. return -1;
  18. return n + m - 2;
  19. }
  20. }
  21.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class RobotOnMoon is public, should be declared in a file named RobotOnMoon.java
public class RobotOnMoon
       ^
1 error
stdout
Standard output is empty