Gidhub BE Developer

[Programmers] 탑

2018-09-27
goodGid

Problem

Problem URL :


[1] Answer Code (18. 09. 27)

#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<int> heights) {
    vector<int> answer;
    int size = (int) heights.size();
    for(int i=0; i<size; i++){
        int tmp = 0;
        for(int j=i-1; j>=0; j--){
            if(heights[i] < heights[j]){
                tmp = j+1;
                break;
            }
        }
        answer.push_back(tmp);
    }
    return answer;
}

Review


Recommend

Index