반응형

Programming/Programmers 29

프로그래머스 SQL [SUM,MAX,MIN]

최댓값 구하기 -- 코드를 입력하세요 SELECT max(DATETIME) from ANIMAL_INS max를 사용하여 최댓값 출 최솟값 구하기 -- 코드를 입력하세요 SELECT min(DATETIME) from ANIMAL_INS min 사용하여 최솟값 출력 동물 수 구하기 -- 코드를 입력하세요 SELECT count(ANIMAL_ID) as count from ANIMAL_INS count를 사용하여 ANIMAL_ID의 총 개수를 출력 중복 제거하기 -- 코드를 입력하세요 SELECT count(distinct NAME) as count from ANIMAL_INS where NAME is not NULL distinct를 사용하여 중복을 제외하고 where을 사용하여 NULL값을 제외한 NAM..

프로그래머스 1차다트게임 [c++] [2018카카오]

#include #include #include #include #include using namespace std; int solution(string dartResult) { int answer = 0; vectorv; int idx=0; //현재숫자위치를 저장할 인덱스 변수 for(int i=0;i1) //그외에 경우 이전인덱스의 값까지 *2 { v[idx]*=2; v[idx-1]*=2; } idx++; } else if(temp=='#') //현재인덱스의 값 *-1 { v[idx]*=-1; idx++; } } for(int i=0;i 1제곱, D -> 2제곱, T -> 3제곱 // *현점수 및 이전 점수 *2, #은 현점수 *-1 // *앞에 점수없으면 현점수만 *2, *점수 중복가능, # 중복가능

프로그래머스 타겟넘버 [c++] [stack] [level2]

#include #include #include #include #include using namespace std; int res=0; //결과값 저장할 배열 typedef struct { int num; //현재값을 저장할 변수 int cnt; //현재 인덱스를 저장할 변수 }node; void func(int start,vector v, int t) { stacks; s.push({start,0}); //첫번째값 앞에 -,+ 가 있는 경우를 각각 push, 인덱스는 0부터 s.push({start*-1,0}); while(!s.empty()) { int snum = s.top().num; int scnt = s.top().cnt; s.pop(); if(scnt >=v.size()) //인덱스가 ve..

[프로그래머스] 경주로 건설 (c++) (2020카카오인턴십)

#include #include #include #include #include #include #include using namespace std; int map[26][26]; int mapTemp[26][26][4]; int dx[4] = { 0,1,0,-1 }; int dy[4] = { 1,0,-1,0 }; int n; typedef struct { int x; int y; int money; int px; }node; int bfs(int start) { queueq; q.push({ start,start,0,-1}); vectorresult; fill(&mapTemp[0][0][0], &mapTemp[n-1][n][4], 0); //배열0으로 초기화 while (!q.empty()) { int..

[프로그래머스] 여행경로 (c++) (dfs)

#include #include #include #include using namespace std; int visited[10001]; void func(string str, vector& temp_tic,vector& tic, int cnt,vector& result) { temp_tic.push_back(str); //임시 vector에 ICN을 시작으로 이후 목적지 저장 if(cnt == tic.size() && result.size()==0) //cnt의 값이 총 티켓의 수와 같으며, result의 크기가 0인 경우 { result = temp_tic; //result에 저장 후 종료 return; } for(int i=0;i

반응형