fork download
  1. public class StringTransformation {
  2. char[] s, t;
  3. int[][][] dp;
  4. int[] get;
  5.  
  6. public int findIt(int ss, int tt, int nex) {
  7. if (ss == -1 && tt == -1) return 1;
  8. if (ss < 0 || tt < 0) return 0;
  9. if (dp[ss][tt][nex] != -1) return dp[ss][tt][nex];
  10. dp[ss][tt][nex] = 0;
  11. if (s[ss] == t[tt]) dp[ss][tt][nex] |= findIt(ss - 1, tt - 1, get[s[ss]]);
  12. if (ss < s.length - 1 && ss - 2 >= 0 && nex != get[s[ss - 2]] && s[ss - 1] == s[ss])
  13. dp[ss][tt][nex] |= findIt(ss - 2, tt, nex);
  14. return dp[ss][tt][nex];
  15. }
  16.  
  17. public String getResult(String s, String t) {
  18. this.s = s.toCharArray();
  19. this.t = t.toCharArray();
  20. dp = new int[this.s.length][this.t.length][3];
  21. get = new int[256];
  22. get['R'] = 0;
  23. get['G'] = 1;
  24. get['B'] = 2;
  25. for (int i = 0; i < this.s.length; i++) {
  26. for (int j = 0; j < this.t.length; j++) {
  27. Arrays.fill(dp[i][j], -1);
  28. }
  29. }
  30. int temp = 0;
  31. temp |= findIt(this.s.length - 1, this.t.length - 1, 0);
  32. temp |= findIt(this.s.length - 1, this.t.length - 1, 1);
  33. temp |= findIt(this.s.length - 1, this.t.length - 1, 2);
  34. if (temp == 1) return "YES";
  35. else return "NO";
  36. }
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class StringTransformation is public, should be declared in a file named StringTransformation.java
public class StringTransformation {
       ^
Main.java:27: error: cannot find symbol
                Arrays.fill(dp[i][j], -1);
                ^
  symbol:   variable Arrays
  location: class StringTransformation
2 errors
stdout
Standard output is empty