CodingTest Practice/Programmers 35

프로그래머스 : 신규 아이디 추천 (C++, Lv.1)

https://programmers.co.kr/learn/courses/30/lessons/72410?language=cpp 코딩테스트 연습 - 신규 아이디 추천 카카오에 입사한 신입 개발자 네오는 "카카오계정개발팀"에 배치되어, 카카오 서비스에 가입하는 유저들의 아이디를 생성하는 업무를 담당하게 되었습니다. "네오"에게 주어진 첫 업무는 새로 programmers.co.kr 문자열 다루기 너무 어려워서 우선 할 수 있는 최대한의 방법으로 코드를 짜봤다. 나중에 문자열 더 열심히 해서 더 줄여봐야지. 다른 사람 코드 풀이보면 엄청 간결하게 잘 짰던데... #include #include using namespace std; string solution(string new_id) { string answe..

프로그래머스 : 문자열 다루기 기본 (C++)

https://programmers.co.kr/learn/courses/30/lessons/12918?language=cpp 코딩테스트 연습 - 문자열 다루기 기본 문자열 s의 길이가 4 혹은 6이고, 숫자로만 구성돼있는지 확인해주는 함수, solution을 완성하세요. 예를 들어 s가 "a234"이면 False를 리턴하고 "1234"라면 True를 리턴하면 됩니다. 제한 사항 s는 길이 1 programmers.co.kr isdigit 함수를 본 기억이 있었으나 어떻게 제대로 쓰는지 몰라서 인터넷에 검색해봤다. https://blockdmask.tistory.com/362 [C언어/C++] isdigit (숫자를 판단하는 함수) 안녕하십니다. BlockDMask 입니다. 오늘은 C언어 및 C++에서 문..

프로그래머스 : 모의고사 (C++, Lv.1)

#include #include using namespace std; int supoja_1[] = {1, 2, 3, 4, 5}; int supoja_2[] = {2, 1, 2, 3, 2, 4, 2, 5}; int supoja_3[] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; //1번 수포자 패턴 : 1, 2, 3, 4, 5 //2번 수포자 패턴 : 2, 1, 2, 3, 2, 4, 2, 5 //3번 수포자 패턴 : 3, 3, 1, 1, 2, 2, 4, 4, 5, 5 vector solution(vector answers) { vector answer; //인원별 정답 갯수 변수 int ans_1 = 0, ans_2 = 0, ans_3 = 0; //현재 문제번호 변수 int cur_num..

프로그래머스 : 로또의 최고 순위와 최저 순위 (C++, Lv.1)

#include #include #include using namespace std; vector solution(vector lottos, vector win_nums) { vector answer; int x= 0, same = 0; sort(lottos.begin(), lottos.end()); sort(win_nums.begin(),win_nums.end()); int l_point = 0, w_point = 0; while(l_point < 6 && w_point < 6){ //0이 있는 경우 if(lottos[l_point] == 0) { x++; l_point++; continue; } //같은 경우 if(lottos[l_point] == win_nums[w_point]) { same++; ..

프로그래머스 : 기능개발 (C++)

아래 블로그를 참고해 작성한 코드임을 명시합니다. https://ongveloper.tistory.com/76 프로그래머스 기능개발 c++ (스택/큐) 문제 출처 : https://programmers.co.kr/learn/courses/30/lessons/42586 코딩테스트 연습 - 기능개발 프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있.. ongveloper.tistory.com 코드1 벡터progresses에 벡터speeds값을 매번 더해 맨앞원소가 100 이상인지 확인하고, 이상이면 벡터의 값을 큐q에 넣어 q.front()가 100이 넘는지 확인 #include #include #include using namespace std;..