목록코딩테스트 (73)
bdfgdfg
#include #include #include #include using namespace std; bool compare(string& left, string& right) { string ret = left + right; string ret2 = right + left; return atoi(ret.c_str()) > atoi(ret2.c_str()); } string solution(vector numbers) { string answer = ""; vector cmpNum; for (auto num : numbers) cmpNum.push_back(to_string(num)); sort(cmpNum.begin(), cmpNum.end(), compare); if(cmpNum[0] == "0")..
#include #include #include using namespace std; int solution(vector scoville, int K) { int answer = 0; priority_queue pq; int len = scoville.size(),i; for(i = 0; i = K) return answer = -1; while(true) { int firstSco = pq.top(); pq.pop(); int secondSco = pq.top(); pq.pop(); if(firstSco >= K) break; else { int res = firs..
#include #include #include using namespace std; int res; void DFS(vector& numbers, int target, int sum, int count, int idx) { if (sum == target && count == numbers.size()) { ++res; return; } if (idx >= numbers.size()) return; DFS(numbers, target, sum + numbers[idx], count + 1,idx + 1); DFS(numbers, target, sum - numbers[idx], count + 1,idx + 1); } int solution(vector numbers, int target) { strin..
#include #include using namespace std; vector solution(vector prices) { vector answer; bool exit; int count,Len = prices.size(),i,j; for(i = 0; i prices[j]) break; else ++count; } if(j == Len) // 마지막 주가. 비교대상이 없으므로 0 { answer.push_back(0); break; } answer.push_back(count); } return answer; }