We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include <string> #include <vector> #include <algorithm> using namespace std; bool desc(string a, string b) { int a_size = a.length(); char a_init = a[0] - '\0'; char b_init = b[0] - '\0'; int b_size = b.length(); if(a_size == b_size) return a > b; else if (a_size > b_size) { for (int i = 0; i < b_size; i++) { if (a[i] == b[i]) continue; return a > b; } int size = b_size; if (a[size] > a[size - b_size]) return a > b; else if (a[size] < a[size - b_size]) return a < b; else { while(++size < a_size){ if (a[size] == a[size-b_size])continue; else if (a[size] > a[size-b_size]) return a > b; else return a < b; } for(int i=0;i<b_size;i++, size++){ if (b[i] == a[size - b_size])continue; else if (b[i] > a[size - b_size]) return a > b; else return a < b; } } } else { for (int i = 0; i < a_size; i++) { if (a[i] == b[i]) continue; return a > b; } int size = a_size; if (b[size] > b[size-a_size]) return a > b; else if (b[size] < b[size-a_size]) return a < b; else { while(++size < b_size){ if (b[size] == b[size-b_size])continue; else if (b[size] > b[size-b_size]) return a > b; else return a < b; } for(int i=0;i<a_size;i++, size++){ if (a[i] == b[size - a_size])continue; else if (a[i] > b[size - a_size]) return a > b; else return a < b; } } } } string solution(vector<int> numbers) { vector<string> str_numbers; string answer = ""; for (auto iter = numbers.begin(); iter < numbers.end(); iter++) { string bmp = to_string(*iter); str_numbers.push_back(bmp); } sort(str_numbers.begin(), str_numbers.end(), desc); for (auto iter = str_numbers.begin(); iter < str_numbers.end(); iter++) { answer += *iter; } if (answer[0] == '0')answer = "0"; return answer; }
추가한 테스트케이스 [40,403 ] [40,405] [40,404] [12,121] [2,22,223] [21,212] [41,415] [2,22 ] [70,0,0,0] [0,0,0,0] [0,0,0,1000] [12,1213]
테스트케이스#1 ~ #6이 계속 실패해서 질문하기에 있는 테스트케이스를 다 통과했는데도 실패해서 질문올려봅니다
The text was updated successfully, but these errors were encountered:
[54554554, 545] "54554554554" [5455455, 545] "5455455545" 이거 추가해보세요. 써주신 테스트 케이스 [12, 121] 보고 힌트를 얻어서 고안했습니다. 덕분에 해결했습니다.
Sorry, something went wrong.
No branches or pull requests
추가한 테스트케이스
[40,403 ]
[40,405]
[40,404]
[12,121]
[2,22,223]
[21,212]
[41,415]
[2,22 ]
[70,0,0,0]
[0,0,0,0]
[0,0,0,1000]
[12,1213]
테스트케이스#1 ~ #6이 계속 실패해서 질문하기에 있는 테스트케이스를 다 통과했는데도 실패해서 질문올려봅니다
The text was updated successfully, but these errors were encountered: