Beruflich Dokumente
Kultur Dokumente
class Sample {
/**
* @param list a result of permutation, e.g. {"ab", "ba"}
* @param c the last character
* @return a merged new list, e.g. {"cab", "acb" ... }
*/
public static ArrayList<String> merge(ArrayList<String> list, String c) {
ArrayList<String> res = new ArrayList<String>();
// Loop through all the string in the list
for (String s : list) {
// For each string, insert the last character to all possible postions
// and add them to the new list
for (int i = 0; i <= s.length(); ++i) {
String ps = new StringBuffer(s).insert(i, c).toString();
res.add(ps);
}
}
return res;
}
}
}
return max;
}
}
//Zadatak 2
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
class Solution {
return max;
}
public Solution() {
root = new Tree();
root.x =4;
Tree rootL = new Tree();
rootL.x = 5;
Tree rootLL = new Tree();
rootLL.x = 4;
Tree rootLLL = new Tree();
rootLLL.x = 5;
rootLL.l = rootLLL;
root.r = rootR;
}
System.out.println(sol.solution(sol.root, sol));
}