728x90

공부/C# 37

[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 =..

공부/C# 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 등 사용 1. Dictionary키-값(key-value) 쌍을 저장하는 자료구조key를 기준으로 value를 빠르게 찾을 수 있음중복된 키를 허용하지 않으며, key를 사용해 데이터를 조회하거나 수정 가능내부적으로 해시 테이블을 사용하여 평균적으로 O(1)의 접근 속도를 가짐value가 중요할 때 사용Contains가 아닌 ContainsKey사용접근시 dic[key] 로 접근var a = new Dictionary();var myTable = new Dictionary(); myTable..

공부/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
728x90
반응형