250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Tags
- joystick
- Prefabs
- raycasting
- Object Poling
- Unity
- LayerMark
- 플레이어 방향전환
- Object Pooling
- Scrooling
- rigidbody
- 프리팹
- 패럴렉스
- 유니티
- Ainimation Blending
- 오브젝트 풀링
- apk
- Blend Type
- 2D슈팅게임
- rotation
- 플레이어 이동
- Animation State Machine
- 스크롤링
- Vector3
- raycast
- CSharp #자료구조
- Hp바
- Transform
- Parallax
- 일시정지
- Hpbar
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 피로도 본문
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/87946
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 정답코드 및 핵심 아이디어, 유의사항
조건에 따라 현재 피로도로 가장 많은 던전을 구하는 경우의 클리어 던전 횟수를 반환하는 문제
- 입장 조건 최소 피로도로 인해 변수가 많아 모든 경우의 수를 구해야 함
-> DFS 알고리즘을 이용해 모든 경우의 수를 구함
https://godgjwnsgur7.tistory.com/47
[Algorithm C#] BFS, DFS ( + Back Tracking )
1. BFS(Breadth First Search) - 너비 우선 탐색 최단 경로, 임의의 경로를 찾고 싶을 때, 등에 사용 - 큐(FIFO) 사용 // 큐를 이용 public void BFS(int index) { Node root = nodes[index]; Queue queue = new Queue(); queue.Enqueue(root
godgjwnsgur7.tistory.com
풀이 과정
using System;
public class Solution
{
public int solution(int k, int[,] dungeons)
{
int answer = 0; // 최대로 클리어 할 수 있는 던전 개수
var boolArray = new bool[dungeons.GetLength(0)]; // 방문 배열
DFS(dungeons, k, boolArray, 0, ref answer); // 완전탐색
return answer;
}
public void DFS(int[,] dungeons, int k, bool[] boolArray, int clearCount, ref int answer)
{
for(int i = 0; i < dungeons.GetLength(0); i++)
{
// 이미 클리어 했거나 클리어 할 수 없는 던전이라면
if(boolArray[i] || k < dungeons[i, 0])
continue;
boolArray[i] = true;
DFS(dungeons, k - dungeons[i, 1], boolArray, clearCount + 1, ref answer);
boolArray[i] = false;
}
answer = Math.Max(answer, clearCount);
}
}
728x90
'Programmers - C# > CodingTest Lv.2' 카테고리의 다른 글
[프로그래머스 C#] Lv.2 과제 진행하기 (0) | 2024.05.22 |
---|---|
[프로그래머스 C#] Lv.2 유사 칸토어 비트열 (0) | 2024.04.01 |
[프로그래머스 C#] Lv.2 혼자 놀기의 달인 (0) | 2024.03.20 |
[프로그래머스 C#] Lv.2 교점에 별 만들기 (1) | 2024.03.18 |
[프로그래머스 C#] Lv.2 조이스틱 (2) | 2024.03.16 |