코딩공부 221

[프로그래머스]Lv.2 프로세스C#

https://school.programmers.co.kr/learn/courses/30/lessons/42587 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; using System.Linq; using System.Collections.Generic; public class Solution { public int solution(int[] priorities, int location) { int answer = 0; Queue q = new Queue(); for (int i = 0; i < priorities.Len..

[프로그래머스]Lv.2 큰 수 만들기C#

https://school.programmers.co.kr/learn/courses/30/lessons/42883/solution_groups?language=csharp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; using System.Text; public class Solution { public string solution(string number, int k) { int size = number.Length - k; int idx = 0; StringBuilder strArr = new StringBuilde..

※[프로그래머스]Lv.2 타겟 넘버C#

https://school.programmers.co.kr/learn/courses/30/lessons/43165?language=csharp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; using System.Collections.Generic; using System.Linq; public class Solution { List results = new List(); public int solution(int[] numbers, int target) { DFS(numbers, target, 0, 0); return ..

[프로그래머스]Lv.2 스킬트리C#

https://school.programmers.co.kr/learn/courses/30/lessons/49993#fnref1 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; using System.Collections.Generic; public class Solution { public int solution(string skill, string[] skill_trees) { int answer = skill_trees.Length; char[] skills = skill.ToCharArray(); for (int i ..

[프로그래머스]Lv.0 코드 처리하기C++ (string::empty)

https://school.programmers.co.kr/learn/courses/30/lessons/181932 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 #include #include using namespace std; string solution(string code) { string answer = ""; int mode = 0; for (int i = 0; i < code.size(); i++) { if (code[i] == '1') { mode = mode == 0 ? 1 : 0; continue; } if (mode == 0..

※[프로그래머스]Lv.2 방문 길이C# (양방향 비교하기)

https://school.programmers.co.kr/learn/courses/30/lessons/49994 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 문제에 함정이있었다 처음에 2차배열로 풀었지만 양방향으로 비교를 했다. using System; using System.Collections.Generic; public class Solution { public int solution(string dirs) { int answer = 0; bool[,,,] visit = new bool[11, 11, 11, 11]; Queue q = n..

※[프로그래머스]Lv.2 삼각 달팽이C# (나머지값으로 방향구하기)

https://school.programmers.co.kr/learn/courses/30/lessons/68645 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; using System.Collections.Generic; public class Solution { public int[] solution(int n) { List answer = new List(); int[,] board = new int[n, n]; int num = 1; int y = -1; int x = 0; for (int i = 0; i < n; ..

※[프로그래머스]Lv.2 마법의 엘리베이터C# (곱셈 나눗셈으로 나머지)

https://school.programmers.co.kr/learn/courses/30/lessons/148653 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드1(시간복잡도 오류) using System; using System.Collections.Generic; using System.Linq; public class Solution { public int solution(int storey) { int answer = 0; string str = storey.ToString(); Dictionary dic = new Dictionary()..

[프로그래머스]Lv.2 이진 변환 반복하기 C#

https://school.programmers.co.kr/learn/courses/30/lessons/70129 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; public class Solution { public int[] solution(string s) { int[] answer = new int[2]; string binary = s; while (binary.Length > 1) { for (int i = 0; i < binary.Length; i++) { if (binary[i] == '0') answer[1..

[자료구조] 달팽이 알고리즘 C#

달팽이 알고리즘(Snail Sort 또는 Spiral Order Traversal)은 행렬(matrix)을 처음부터 끝까지 달팽이의 움직임과 유사하게 순회하는 알고리즘입니다. 이 알고리즘은 행렬의 각 원소를 한 번씩만 방문하면서 순회합니다. 알고리즘의 움직임은 아래와 같습니다: 첫 번째 행을 왼쪽에서 오른쪽으로 순회합니다. 마지막 열을 위에서 아래로 순회합니다. 마지막 행을 오른쪽에서 왼쪽으로 순회합니다. 첫 번째 열을 아래에서 위로 순회합니다. 이 과정을 반복하면서 행렬의 중앙까지 진행하게 됩니다. 만약 행과 열의 크기가 홀수인 경우에는 마지막 단계에서 중앙에 위치한 원소가 중복해서 방문되게 됩니다. 다음은 3x3 행렬에 대한 달팽이 알고리즘의 동작 예시입니다: 1 2 3 8 9 4 7 6 5 이 알고..