DSA Day 63/100

DSA Day 63/100

Topic: Queue

Questions Successfully Completed: 1

1) Queue Reversal

Easy

 public Queue<Integer> rev(Queue<Integer> q){
        //add code here.
        // Make Queue -> Stack 
        Stack<Integer> sq = new Stack<>();


        while(q.size()>0){
             sq.push(q.remove());
        }

         while(sq.size()>0){
            q.add(sq.pop());
        }
        return q;

    }

Thank you for reading :)