Advertisement
Guest User

Untitled

a guest
Jul 11th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. class Index {
  2.  
  3. public static void combine(ArrayList<String> teams, ArrayList<String> result, int m) {
  4. if (result.size() >= m) {
  5. println(result);
  6. return;
  7. }
  8. for (int i = 0; i < teams.size(); i++) {
  9. ArrayList<String> newResult = (ArrayList<String>) result.clone();
  10. newResult.add(teams.get(i));
  11. ArrayList<String> surplusTeams = new ArrayList(teams.subList(i + 1, teams.size()));
  12. combine(surplusTeams, newResult, m);
  13. }
  14. }
  15.  
  16. public static void main(String[] args) throws Exception {
  17. combine(new ArrayList<>(Arrays.asList("T1", "T2", "T3", "T4")), new ArrayList<>(), 2);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement