1. var CQueue = function () {
    2. this.stack1 = []
    3. this.stack2 = []
    4. };
    5. /**
    6. * @param {number} value
    7. * @return {void}
    8. */
    9. CQueue.prototype.appendTail = function (value) {
    10. this.stack1.push(value)
    11. };
    12. /**
    13. * @return {number}
    14. */
    15. CQueue.prototype.deleteHead = function () {
    16. if (this.stack2.length) {
    17. return this.stack2.pop()
    18. } else if (this.stack1.length) {
    19. while (this.stack1.length) {
    20. this.stack2.push(this.stack1.pop())
    21. }
    22. return this.stack2.pop()
    23. }
    24. return -1;
    25. };
    26. /**
    27. * Your CQueue object will be instantiated and called as such:
    28. * var obj = new CQueue()
    29. * obj.appendTail(value)
    30. * var param_2 = obj.deleteHead()
    31. */