Bomb Kirby Running
Cat Life - GT-K
12915번 문자열 내 마음대로 정렬하기

2023. 3. 27. 09:04Programmers

코딩테스트 연습 - Level 1 - 문자열 내 마음대로 정렬하기

https://programmers.co.kr/learn/courses/30/lessons/12915

#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int m;
bool cmp(string a,string b)
{
    if(a[m]==b[m])
    {
        return a<b;
    }
    
    else
    {
        return a[m]<b[m];
    }
}

vector<string> solution(vector<string> strings, int n) {
    vector<string> answer;
    m=n;
    sort(strings.begin(),strings.end(),cmp);
    
    return strings;    
}