[프로그래머스/C++] 접미사 배열

꿈별·2023년 8월 22일
0

문제풀이

목록 보기
25/52

문제


풀이

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<string> solution(string my_string) {
    vector<string> answer;
    string temp = "";

    for (int i = 0; i < my_string.length(); i++)
    {
        for (int j = i; j < my_string.length(); ++j)
        {
            temp += my_string[j];
        }
        answer.push_back(temp);
        temp = "";
    }
    sort(answer.begin(), answer.end());

    return answer;
}

0개의 댓글