title: Finding distinct numbers in queue using java
body: <p>I want to find distinct numbers in a queue but I can't use anything but a queue such as an array or etc.</p>
  <p>Here is my code:</p>
  <pre><code>    Queue distinct = new Queue(10);
      Queue distincttemp1 = new Queue(10);
      
      int count=0;
      Random rnd = new Random();
      boolean flag=true;
      for (int i = 0; i &lt; 10; i++) {
          int x = rnd.nextInt(9);
          System.out.print(x + &quot; &quot;);
          distinct.enqueue(x);
      }
      System.out.println(&quot;&quot;);
  </code></pre>
  <p>I couldn't find a solution finding how many numbers are repeated except adding every each number to a queue. It should be simple with a few loops. Can you help me find an algorithm?</p>
  <p>Input and output should be like this:</p>
  <blockquote>
  <p>Queue: 4 8 5 8 4 3 2 8</p>
  </blockquote>
  <blockquote>
  <p>Output: 5</p>
  </blockquote>