[프로그래머스] 문자열 내 마음대로 정렬하기

Zoo Da·2022년 2월 8일
0

프로그래머스

목록 보기
10/10
post-thumbnail

링크

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

sol1) 정렬

#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/rope>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

vector<string> solution(vector<string> strings, int n) {
    vector<string> answer;
    sort(strings.begin(),strings.end(),[&](const string& a,const string& b){
        if(a[n] == b[n]) return a < b;
        return a[n] < b[n];
    });
    answer = strings;
    return answer;
}
profile
메모장 겸 블로그

0개의 댓글