28279번1 [백준/BOJ][C++] 28279번 덱 2 #include #include using namespace std; struct Deque { private: int* elements; int frontIndex; int backIndex; int MAX_SIZE; public: Deque(int n) { elements = new int[n]; frontIndex = 0; backIndex = 0; MAX_SIZE = n; } void push_front(int x) { // front는 0부터 뒤로가면서 원소를 삽입 elements[frontIndex] = x; frontIndex = ((frontIndex - 1) + MAX_SIZE) % MAX_SIZE; } void push_back(int x) { // back은 1부터 앞으로가면서 원소를.. 2023. 8. 26. 이전 1 다음