fork download
  1. public class OnlySanta {
  2. boolean containsSubsequence(String a, String b) {
  3. int i = 0;
  4. for(int j = 0; j < b.length(); ++j)
  5. while(i < a.length() && a.charAt(i) != b.charAt(j))
  6. ++i;
  7. return i < a.length();
  8. }
  9. public String solve(String S) {
  10. if(!containsSubsequence(S, "S"))
  11. return S + "SANTA";
  12. if(containsSubsequence(S, "SAN")) return S + "TA";
  13. // find first S
  14. int i = 0;
  15. while(S.charAt(i) != 'S') ++i;
  16. return S.substring(0, i + 1) + "AN" + S.substring(i + 1) + "TA";
  17. }
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class OnlySanta is public, should be declared in a file named OnlySanta.java
public class OnlySanta {
       ^
1 error
stdout
Standard output is empty