Notice
Recent Posts
Recent Comments
Today
Total
01-11 01:45
Link
๊ด€๋ฆฌ ๋ฉ”๋‰ด

Partially Committed

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋ฌธ์ž์—ด ๋‚ด ๋งˆ์Œ๋Œ€๋กœ ์ •๋ ฌํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿ”ฅ Algorithm || ๋ฌธ์ œํ’€์ด/PS

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋ฌธ์ž์—ด ๋‚ด ๋งˆ์Œ๋Œ€๋กœ ์ •๋ ฌํ•˜๊ธฐ

WonderJay 2022. 7. 6. 22:03
728x90
๋ฐ˜์‘ํ˜•
SMALL

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

 

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”.

programmers.co.kr

๋ฌธ์ œ์—์„œ ์ œ์‹œํ•œ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ์„ ์ˆ˜ํ–‰ํ•˜๋ฉด ๋˜๋Š”๋ฐ, ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ด์šฉํ•ด์•ผ ํ•˜๋ฏ€๋กœ ์บก์ณ ๋ธ”๋ก์— & ๋ฅผ ๋„ฃ์–ด์ฃผ์–ด

Solution ํ•จ์ˆ˜ ์Šค์ฝ”ํ”„ ๋‚ด์˜ ๋ณ€์ˆ˜๋ฅผ ์ฐธ์กฐํ•˜์—ฌ ๋žŒ๋‹ค ํ•จ์ˆ˜์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€๋‹ค.

 

#include <bits/stdc++.h>
#define fastio cin.tie(0)->sync_with_stdio(0)
#define ll long long
using namespace std;

vector<string> solution(vector<string> strings, int n) {
    vector<string> answer;

    answer = strings;
    
    sort(answer.begin(), answer.end(), [&](string a, string b)
        {
            if (a[n] == b[n])
            {
                return a < b;
            }
            return a[n] < b[n];
        });

    return answer;
}

 

728x90
๋ฐ˜์‘ํ˜•
LIST
Comments