::public265 H-index *H-Index(정렬) 논문 n편 중, h번 이상 인용된 논문이 h편 이상 나머지 논문이 h번 이하 인용되었다면 h = H-Index. #include #include #include using namespace std; int solution(vector citations) { int answer = 0; sort(citations.begin(), citations.end(), greater()); int p = 0; while(true) { if(p >= citations[p]) break; p++; } return answer = p; } Colored by Color Scriptercs 2019. 9. 5. 가장 큰 수 *가장 큰 수(정렬 & 문자열) 주어진 배열의 값들로 최대값 만들기. #include #include #include using namespace std; bool compareNum(int a, int b) { string s1 = to_string(a); string s2 = to_string(b); return s1 + s2 > s2 + s1; } string solution(vector numbers) { string answer = ""; sort(numbers.begin(), numbers.end(), compareNum); for(auto elem : numbers) { answer += to_string(elem); } if(answer[0] == '0') answer = '0'; retu.. 2019. 9. 5. 프린터 *프린터(스택/큐) 중요도 대기목록, location 위치의 문서가 몇번째로 인쇄되는지. 인쇄 대기목록의 젤 처음을 꺼냄. 대기목록에서 중요도가 가장 높으면 인쇄. 아니면 젤뒤로 넣음. #include #include #include using namespace std; int solution(vector priorities, int location) { int answer = 0; deque que; for(int i = 0; i 2019. 9. 5. 이상한 문자 만들기 *이상한 문자 만들기 공백을 기준으로 짝수는 대문자 홀수는 소문자 변환하기. 0번째 인덱스는 짝수로 처리. #include #include using namespace std; string solution(string s) { string answer = ""; int count = 0; for(int i = 0; i 2019. 9. 5. 예산 *예산(정렬) 신청한 금액 배열, 예산이 있음. 예산으로 물품 구매 가능한 부서 최대값. #include #include #include using namespace std; int solution(vector d, int budget) { int answer = 0; sort(d.begin(), d.end()); for(int i : d) { budget -= i; if(budget 2019. 9. 5. 시저암호 * 시저암호(string) 각 알파벳을 일정한 거리만큼 밀어서 다른 알파벳으로 바꿈. Z - A, z - a 로 바뀜. 공백은 공백. #include #include using namespace std; string solution(string s, int n) { string answer = ""; int pos; for(int i = 0; i = 'a') ? 'a' : 'A'; answer += pos + (s[i] - pos + n) % 26; } } return answer; } Colored by Color Scriptercs 2019. 9. 5. 이전 1 ··· 34 35 36 37 38 39 40 ··· 45 다음