Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EnthaltenMitAbstand {
- public static void main(String[] args) {}
- public static boolean enthalten(String s, String t, int abstand) {
- if (t.isEmpty()) {
- return true;
- }
- for (int i = 0; i < s.length(); i++) {
- if(recursion(s.substring(i), t, abstand)==true){return true;}
- }
- return false;
- }
- public static boolean recursion(String s, String t, int abstand) {
- if(s.length() > 0){
- String current;
- current = s.substring(0, 1);
- if (t.contains(current)) {
- String substrs;
- String substrt = t.replaceFirst(current, "");
- for (int i = 0; i <= abstand; i++) {
- if(s.length() >i){
- substrs = s.substring(i+1);
- if (true == recursion(substrs, substrt, abstand)) {
- return true;
- }
- }
- }
- }
- }
- if (t.isEmpty()) {
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement