프로그래머스 LV3 - 숫자게임
2022. 11. 30. 09:21ㆍ코딩테스트/프로그래머스
0️⃣ 문제링크
https://school.programmers.co.kr/learn/courses/30/lessons/12987
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1️⃣ 문제 설명
a b 를 둘다 오름차순으로 정렬 한 후
a원소들보다 b에 큰 원소가 있으면 b의 다음 원소를 내는 식으로 풀어보았다.
2️⃣ 내코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int solution(vector<int> A, vector<int> B) {
int answer = 0;
sort(A.begin(),A.end(),greater());
sort(B.begin(),B.end(),greater());
for(int i = 0 ; i < A.size();i++)
if(A[i] < B[answer] )
answer++;
return answer;
}
|
cs |
3️⃣ 참고한 자료
https://ansohxxn.github.io/programmers/109/
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
프로그래머스 LV 3 _ 디스크 컨트롤러 (C++) (0) | 2022.12.14 |
---|---|
프로그래머스 LV3 섬 연결하기 (C++) (0) | 2022.12.13 |
프로그래머스 LV3 - 단어변환 (0) | 2022.11.24 |
프로그래머스 LV3 - 네트워크 (0) | 2022.11.22 |
프로그래머스 LV3 - 최고의 집합 (0) | 2022.11.18 |