C++ 코딩테스트(스택/큐)
1번 문제(탑) #include <vector> #include <iostream> using namespace std; vector solution(vector<int> heights) { vector<int> answer; vector<int>::iterator it; for(int i=heights.size() -1; i >= 0 ;i–) { int ans = 0; for (int j=i-1;j >= 0;j–) { if (heights[i] < heights[j]) { ans = j+1; break; } } it = answer.begin(); it = answer.insert(it, ans); } return …