title: Java Interview question: Make combinations from 2 arrays, with no duplicates and output must be in random
body: <p>The question is:
  Assume there is a Rich Businessman, He has 20 Cars, 50 Watches. He is very particular in maintaining his uniqueness, so he wants a program to select distinct combination of Car and Watch for each day by the conditions given below.
  His requirement is to get a random, non-repeated car and watch for complete cycle of their availability.
  Ex:</p>
  <ol>
  <li>As he as 20 cars, same car should not come for 20 days once used. Also, they should come in random.</li>
  <li>If one day Car 1 and Watch 2 was selected, it should not come for next one month.</li>
  </ol>
  <p>I was approaching the problem to make a list of Pair combinations and populate the list in random, however in doing so I was getting duplicates. So not sure if I should consider using another DS or change my approach altogether to better design and implement this.</p>
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  import java.util.stream.IntStream;
  
  class PairSelector {
  
      private List&lt;Pair&gt; pairs;
  
  
      public PairSelector() {
          pairs = new ArrayList&lt;Pair&gt;();
  
          IntStream.range(0,20).forEach(i -&gt; {
              IntStream.range(0,50).forEach(j -&gt; {
                  if (i != j) {
                      pairs.add(new Pair(i, j));
                  }
              });
  
          });
      }
  
      public Pair getRandomPair() {
          return pairs.get((int) (pairs.size() * Math.random()));
      }
  }
  
  class Pair {
      private int car;
      private int watch;
  
      public Pair(int car, int watch) {
          this.car = car;
          this.watch = watch;
      }
      public int getCar() {
          return car;
      }
      public int getWatch() {
          return watch;
      }
  }
  
  
  public class RichBusinessman {
  
      public static void main(String[] args) {
  
          for (int i = 0; i &lt; 20; i++) {
              PairSelector ps = new PairSelector();
              Pair randomPair = ps.getRandomPair();
  
              int car = randomPair.getCar();
              int watch = randomPair.getWatch();
  
              System.out.println(&quot;car: &quot; + car + &quot;, watch: &quot; + watch);
          }
  
      }
  }
  </code></pre>