SHARE
TWEET

Untitled

a guest Jul 11th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top