99클럽 코테 스터디 19일차 TIL - 프로그래머스 공원 산책 #include using namespace std; pair start; int board[52][52]; vector solution(vector park, vector routes) { vector answer; int re[2]; for(int j=0;j=park.size()||nxt.first=park[0].length()||nxt.second algorithm/문제 풀이 2024.04.19
99클럽 코테 스터디 18일차 TIL - 백준 16953번 (A -> B) #include using namespace std; int A,B; int bfs(int start){ queue q; q.push(pair(start, 1)); while(!q.empty()){ pair x = q.front(); q.pop(); //cout algorithm/문제 풀이 2024.04.18
99클럽 코테 스터디 17일차 TIL - 프로그래머스 전력망을 둘로 나누기 #include #define MAX 101 using namespace std; int cnt; vector graph[MAX]; void bfs(int v1, int v2){ queue q; vector visited(MAX); q.push(v1); visited[v1] = true; visited[v2] = true; while (!q.empty()) { int node = q.front(); q.pop(); for (int i=0; i algorithm/문제 풀이 2024.04.17
99클럽 코테 스터디 16일차 TIL - 프로그래머스 신고 결과 받기 #include using namespace std; vector solution(vector id_list, vector report, int k) { vector answer; map reportList; map reportUser; set temp; for(string id : id_list){ reportList.insert(pair(id, temp)); reportUser.insert(pair(id, 0)); } for(string s: report){ stringstream ss(s); string x, y; ss >> x >>y; set name = reportList.at(x); name.insert(y); reportList.erase(x); reportList.insert(pair(x,.. algorithm/문제 풀이 2024.04.16
99클럽 코테 스터디 15일차 TIL - 백준 15663번 (N과 M (9)) #include using namespace std; bool visited[9]; int re[9]; vector v; vector temp; set s; void solve(int n, int m, int k) { if (m == k) { for (int i = 0; i > M; int arr[9]; fill_n(visited, M, false); fill_n(arr, 9, -1); for (int i = 0; i > a; v.push_back(a); } //sort(v.begin(), v.begin() + v.size()); solve(N, M, 0); for(ve.. 카테고리 없음 2024.04.15
99클럽 코테 스터디 14일차 TIL - 프로그래머스 JadenCase 문자열 만들기 공백문자가 연속으로 나올 수 있고 맨 앞이나 뒤에도 나올 수 있기 때문에 처음에 그냥 split 메서드 이용해서 푸니까 런타임 에러 발생 StringTokenizer 이용 String s= "this-is-sentence"; StringTokenizer st = new StringTokenizer(s, "-", true); while(st.hasMoreTokens()){ System.out.println(st.nextToken()); } /*** this - is - sentence ***/ import java.io.*; import java.util.*; class Solution { public String solution(String s) { String answer = ""; //String s.. algorithm/문제 풀이 2024.04.14
99클럽 코테 스터디 13일차 TIL - 백준 15654 (N과 M (5)) import java.awt.*; import java.util.*; import java.io.*; public class Main { static int N; static int S; static ArrayList list = new ArrayList(); static int[] re; static int[] arr; static boolean[] vi; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); N = I.. algorithm/문제 풀이 2024.04.13
99클럽 코테 스터디 12일차 TIL - 프로그래머스 연속된 부분 수열의 합 배열 for문으로 돌리니까 시간초과 -> 풀이 보니까 투포인터 알고리즘.. import java.io.*; import java.util.*; class Solution { static int[] answer; public int[] solution(int[] sequence, int k) { int[] answer = new int[]{0,sequence.length-1}; int left = 0; int right = 1; int sum = sequence[0]; while(left algorithm/문제 풀이 2024.04.12
99클럽 코테 스터디 11일차 TIL - 백준 14888 (연산자 끼워넣기) 백트래킹으로 모두 탐색... -> 최소값 찾기 import java.awt.*; import java.util.*; import java.io.*; public class Main { static int N; static int[] num; static int[] operator; static int max = Integer.MIN_VALUE; static int min = Integer.MAX_VALUE; static Queue q = new LinkedList(); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));.. algorithm/문제 풀이 2024.04.11
99클럽 코테 스터디 10일차 TIL - 프로그래머스 이진 변환 반복하기 내가 푼 코드 import java.util.*; import java.io.*; class Solution { public int[] solution(String s) { int[] answer = new int[2]; Queue q = new LinkedList(); int changeNum = 0; int zeroNum = 0; while(!s.equals("1")){ zeroNum += s.length()-s.replaceAll("0","").length(); s = s.replaceAll("0",""); int len = s.length(); if(len==1) break; while(len>0){ if(len%2==0){ q.add("0"); len/=2; continue; }if(len%2=.. algorithm/문제 풀이 2024.04.10