Tuesday 28 June 2016

Hackerrank , 30 Days of Code Challenges ( Day 18 Solution)

 Day 18: Queues and Stacks   :

public class Solution {
    // Write your code here.
    Stack<Character> stack = new Stack<Character>();
    Queue<Character> queue = new LinkedList<Character>();
    void pushCharacter(char ch)
        {
        stack.push(ch);
    }
     void enqueueCharacter(char ch){
        queue.add(ch);
     }
    char popCharacter() {
        return stack.pop();
    }

    char dequeueCharacter()
        {
        return queue.remove();
    }

No comments:

Post a Comment