관리 메뉴

기억을 위한 기록들

[HackerRank/C++] Big Sorting 본문

Coding Test - cpp/Sort

[HackerRank/C++] Big Sorting

에드윈H 2021. 7. 1. 11:32

https://www.hackerrank.com/challenges/big-sorting/problem

 

Big Sorting | HackerRank

Sort an array of very long numeric strings.

www.hackerrank.com

#include <bits/stdc++.h>

using namespace std;

bool check(string a, string b){
    return a.length() == b.length() ? a > b : a.length() > b.length();
}

vector<string> bigSorting(vector<string> unsorted) {
    vector<string> result;
   sort(unsorted.begin(),unsorted.end(),check);
    for(int i = unsorted.size() - 1; i >= 0; i--)
    {
        result.push_back(unsorted[i]);
    }
    
    
    return result;
}


hackerrank 풀어보다가 큰수 정렬에 관해