constQueue={in:[],out:[],enqueue:function(x){this.in.push(x);},dequeue:function(){if(this.out.length==0){while(this.in.length!=0){this.out.push(this.in.pop());}}returnthis.out.length==0?"Cannot dequeue":this.out.pop();},front:function(){if(this.out.length==0){while(this.in.length!=0){this.out.push(this.in.pop());}}returnthis.out.length==0?"Cannot show front value":this.out[this.out.length-1];}};
Thursday - Queue from two stacks (Hacker Rank Medium)
Complete the put, pop, and peek methods in the editor below. They must perform the actions as described above.
hackerrank.com/challenges/ctci-que...
Rust Solution:
Perl solution. Passes all the tests on HackerRank.