title: Using queue to rearrange every other integer
body: <p>I'm trying to figure out how to take in an integer and rearrange them so that every alternating character is saved (So the [1, 2, 3, 4, 5, 6] would return [1, 4, 2, 5, 3, 6]). I think a queue would be the best to use for this problem so here's what I have so far. It returns [3, 1, 4, 5, 2, 6], but I'm not sure how I can get it to return the alternating form above :</p>
  <pre><code>import java.util.*;
  public class everyOtherInteger {
  public static void main(String[] args) {
  
      Queue &lt;Integer&gt; sort = new LinkedList&lt;Integer&gt;();
      String s = &quot;123456&quot;;    
  
      for (int i = 0; i &lt; s.length(); i++) {
          sort.add(Integer.parseInt(s.charAt(i) + &quot;&quot;));
  
          if (i%2 == 0) {
              int a = sort.remove();
              sort.add(a);
          }
          else {
  
          }
      }
      
      System.out.println(sort);
  }
  </code></pre>
  <p>}</p>