2017년 12월 23일 토요일

[C++] HackerRank Day18 Solution

/*
https://www.hackerrank.com/challenges/30-queues-stacks/problem

Mind the return type of pop() is void.

*/


#include <iostream>
#include <stack>
#include <queue>


using namespace std;

class Solution {

private:
    stack<char> myStack;
    queue<char> myQueue;
 
public:
 
    void pushCharacter(char ch) {
        myStack.push(ch);
    }
 
    void enqueueCharacter(char ch) {
        myQueue.push(ch);
    }
 
    char popCharacter(){
        char temp = myStack.top();
        myStack.pop();
        return temp;
    }
 
    char dequeueCharacter(){
        char temp = myQueue.front();
        myQueue.pop();
        return temp;
    } 

};

댓글 없음:

댓글 쓰기