#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int chk;
 
bool cmp(string a, string b)
{
    if(a[chk] <= b[chk])
    {
        if(a[chk] == b[chk])
        {
            if(a < b)
            {
                return true;
            }
            else
            {
                return false;
            }
        }   
        
        return true;
    }
    else
    {
        return false;
    }
}
 
vector<string> solution(vector<string> strings, int n) 
{
    vector<string> answer;
    chk = n;
    
    sort(strings.begin(), strings.end(), cmp);
 
    answer = strings;
    
    return answer;
}
cs

+ Recent posts