fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner s = new Scanner(System.in);
  14. String firstString = s.nextLine();
  15. String secondString = s.nextLine();
  16.  
  17. Ideone id = new Ideone();
  18. id.matchStrings(firstString,secondString);
  19.  
  20. }
  21.  
  22. void matchStrings(String one,String two)
  23. {
  24. if(two.length() == 0 || two == null || one.length()==0 || one ==null)
  25. System.out.println(one);
  26. else
  27. {
  28.  
  29. String match = one.replace(String.valueOf(two.charAt(0)),"");
  30. matchStrings(match,two.substring(1,two.length()));
  31. }
  32. }
  33. }
Success #stdin #stdout 0.09s 35484KB
stdin
abcd
cd
stdout
ab