728x90

공부/C++ 6

[C++] 프로그래머스 전화번호 목록

https://school.programmers.co.kr/learn/courses/30/lessons/42577 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr1. sort 사용을 위한 #include2. 오름차순으로 정렬 sort(vec.begin(), vec.end());3. 앞뒤에 붙어있는 애들이 포함하는지 확인 "string".find("string") == 0 이면 포함#include #include #include // sort 사용using namespace std;bool solution(vector phone_book) { bool answer = true; sort(pho..

공부/C++ 2025.04.04

[C++] 프로그래머스 완주하지 못한 선수

*해시맵을 사용하자 (해시맵 = unordered_map)#include  unordered_map count_map; //(string, int) 쌍을 가지는 count_map 이름의 해시맵 선언참가자 이름을 세서 count_map에 넣고, 완주자의 이름이 있으면 개수 하나씩 빼기.(string, int)쌍의 pair에서 pair.second인 int값이 0보다 큰 이름을 반환 #include #include #include #include using namespace std;string solution(vector participant, vector completion) { unordered_map count_map; for (string name : participant) { ..

공부/C++ 2025.04.04

[C++] 코딩테스트 참고

1. vector#include 선언vector vec; //빈 벡터 선언vectorint> a(10); //int형 벡터 10개 선언vector int> b = { 0, 1, 2 }; //이렇게 초기화된 벡터 선언vec.push_back(넣을 값) //push_back으로 넣기 vec.size() //벡터 요소 개수vec.swap(vector객체) //두 벡터의 내용을 교환(교체)vec.empty() //벡터가 비었는지 여부를 반환vec.at(index) //index번째 요소에 접근vec.front() //벡터의 첫 번째 요소를 반환vec.back() //벡터의 마지막 요소를 반환vec.begin() //벡터의 첫 번째 요소 가르킴vec.end()  //벡터의 마지마가 요소 가르킴 #include..

공부/C++ 2025.04.04
728x90
반응형