title: How to implement a queue with three stacks?
body: <p>I came across this question in an algorithms book (<a href="https://rads.stackoverflow.com/amzn/click/com/032157351X" rel="noreferrer" rel="nofollow noreferrer">Algorithms, 4th Edition</a> by Robert Sedgewick and Kevin Wayne).  </p>
  
  <blockquote>
    <p>Queue with three stacks. Implement a queue with three stacks so that each queue operation takes a constant (worst-case) number of stack operations. Warning : high degree of difficulty.</p>
  </blockquote>
  
  <p>I know how to make a queue with 2 stacks but I can't find the solution with 3 stacks. Any idea ?  </p>
  
  <p>(oh and, this is not homework :) )</p>