Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Index {
- public static void combine(ArrayList<String> teams, ArrayList<String> result, int m) {
- if (result.size() >= m) {
- println(result);
- return;
- }
- for (int i = 0; i < teams.size(); i++) {
- ArrayList<String> newResult = (ArrayList<String>) result.clone();
- newResult.add(teams.get(i));
- ArrayList<String> surplusTeams = new ArrayList(teams.subList(i + 1, teams.size()));
- combine(surplusTeams, newResult, m);
- }
- }
- public static void main(String[] args) throws Exception {
- combine(new ArrayList<>(Arrays.asList("T1", "T2", "T3", "T4")), new ArrayList<>(), 2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement