코딩 테스트 맨텀 2023. 4. 29. 16:13
출처: 프로그래머스 코딩 테스트 연습 https://school.programmers.co.kr/learn/courses/30/lessons/169199 나의 풀이 public int solution(string[] board) { (int y, int x) target = (-1, -1); var open = new Queue(); var dist = new int[board.Length, board[0].Length]; // 초기 세팅 for(int y = 0; y < board.Length; ++y) { for(int x = 0; x < board[0].Length; ++x) { if(board[y][x] == 'D') dist[y, x] = -1; else if(board[y][x] == 'R')..
코딩 테스트 맨텀 2023. 4. 19. 22:53
출처: 프로그래머스 코딩 테스트 연습 https://school.programmers.co.kr/learn/courses/30/lessons/142085# 1차 시도 public int solution(int n, int k, int[] enemy) { int size = enemy.Length; if(k >= size) return size; var used = new int[k]; // 무적권을 사용한 스테이지의 인덱스 int minValue = int.MaxValue; int minIndex = 0; // 최소 값이 들어있는 used 배열 내에서의 인덱스 // 미리 k개를 사용한다. for(int i = 0; i enemy[i])..
코딩 테스트 맨텀 2023. 4. 16. 19:38
출처: 프로그래머스 코딩 테스트 연습 https://school.programmers.co.kr/learn/courses/30/lessons/150369 나의 코드 public long solution(int cap, int n, int[] deliveries, int[] pickups) { long answer = 0; int deliverIndex = Array.FindLastIndex(deliveries, (f) => f != 0); // 가장 먼 집부터 배달가야 함. int pickupIndex = Array.FindLastIndex(pickups, (f) => f != 0); // 가장 먼 집부터 회수해야 함. while(deliverIndex >= 0 || pickupIndex >= 0) { ..
코딩 테스트 맨텀 2023. 4. 15. 13:59
출처: 프로그래머스 코딩 테스트 연습 https://school.programmers.co.kr/learn/courses/30/lessons/176962 나의 풀이 public class Test { public string name; public int start; public int remain; public Test(string name, string timeStr, string playTimeStr) { this.name = name; string[] splited = timeStr.Split(':'); start = int.Parse(splited[0]) * 60 + int.Parse(splited[1]); remain = int.Parse(playTimeStr); } } public strin..
코딩 테스트 맨텀 2023. 4. 14. 23:30
출처: 프로그래머스 코딩 테스트 연습 https://school.programmers.co.kr/learn/courses/30/lessons/181187 나의 풀이 public long solution(int r1, int r2) { long answer = 0; long rr1 = (long)r1 * (long)r1; long rr2 = (long)r2 * (long)r2; // 1사분면에 있는 r2 ~ r1 사이의 점들을 구한다. // 단, y == 0일때는 제외한다. 따라서 (x == r2) 도 제외. for(long x = 0; x = r1) { double y = Math.Sqrt(rr..
코딩 테스트 맨텀 2023. 4. 13. 22:09
출처: 프로그래머스 코딩 테스트 연습 https://school.programmers.co.kr/learn/courses/30/lessons/181188 나의 풀이 public int solution(int[,] targets) { var list = new List(); for(int i = 0; i o.Item1).ToList(); int answer = 0; int tail = int.MaxValue; foreach((int start, int end) point in list) { if(point.end < tail) { tai..