Skip to content

Commit

Permalink
이슈 #385에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
1 parent bd4e252 commit b2146d0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Programmers/특이한_정렬.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> solution(vector<int> numlist, int n) {

sort(numlist.begin(), numlist.end(), [n](int a, int b) {
int distA = abs(a - n);
int distB = abs(b - n);

if (distA == distB) {
return a > b;
}

return distA < distB;
});

return numlist;
}

0 comments on commit b2146d0

Please sign in to comment.