728x90

분류 전체보기 115

[C#] 프로그래머스 동적 프로그래밍 - N으로 표현

https://school.programmers.co.kr/learn/courses/30/lessons/42895 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 동적 프로그래밍은 코드는 쉬운데 코드 구현 개념이 너무 어려운듯,,using System;using System.Collections.Generic;public class Solution { public int solution(int N, int number) { if (number == N) return 1; HashSet[] dp = new HashSet[9]; for (int i =..

카테고리 없음 2025.03.09

[C#] 프로그래머스 스택/큐 - 프로세스

https://school.programmers.co.kr/learn/courses/30/lessons/42587 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr using System;using System.Collections.Generic;public class Solution { public int solution(int[] priorities, int location) { int answer = 0; Queue queue = new Queue(); //index, priority for (int i = 0; i

공부/C# 2025.03.09

[C#] 코딩테스트에서 쓰는 함수 / 변수

유니티만 하다가 와서 코딩테스트때 유용할 함수 / 변수를 잘 사용하지 못할까봐 나를 위해 모아둔다 using System.Collections.Generic; -> List, Queue 사용 *Dictionary 사용법 익히기 bool[] visited = new bool[크기];array.Length;array.GetLength(0);Array.Sort(array);Array.Reverse(array); ListList list = new List();- list.Contains(a) -> true / false- list.Add(a) QueueQueue queue = new Queue();- queue.Enqueue((0, 0)); - queue.Dequeue(); StackStack stack = ..

공부/C# 2025.03.07

[C#] 프로그래머스 백트래킹 - 피로도

https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr1. DFS 위주로 생각2. 방문 확인을 위한 visited, 현재 피로도 값 저장3. public int answer로 표시한 정답값을 자주 업데이트 해주기using System;public class Solution { public int answer = -1; public void DFS(bool[] visited, int[,] dungeons, int currentP, int max){ if (max > answer..

공부/C# 2025.03.07

[C#] 프로그래머스 백트래킹 - 소수 찾기

1. 중복 방지를 위해 List에서 .Contains(num)을 사용 / 중복 방지용으로 visited2. 소수 판별 함수 구현3. 모두 방문해 string으로 +하고 DFS 결과로 int count를 내보내기using System;using System.Collections.Generic;public class Solution { List foundPrimes = new List(); // 중복 방지용 리스트 // 소수 판별 함수 public bool isPrime(int num) { if (num 0) { int num = int.Parse(currentNumber); // 중복되지 않은 숫자이고, 소수라면 카운트 증가 ..

공부/C# 2025.03.07

[C#] 프로그래머스 BFS 연습 - 미로 탈출

https://school.programmers.co.kr/learn/courses/30/lessons/159993 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr진짜 푸는데 한시간 넘게 걸린듯,,,아직 BFS가 익숙하지 못해서 인듯 풀이 과정1. string[] 형태의 maps를 2차원 char 배열로 바꾸기 + 바꾸면서 S, L, E의 위치 표시해두기2. S -> L 와 L->E로 나누기3. BFS 구현하기using System;using System.Collections.Generic;public class Solution { public int solution(string[] maps) { ..

카테고리 없음 2025.03.07
728x90