코딩공부 221

※[프로그래머스]Lv.2 모음 사전 C#(순열)

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

※[프로그래머스]Lv.2 피로도 C#(순열)

https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 미뤄두고 있던 순열을 공부하기에 좋았던 문제였다. using System; using System.Collections.Generic; public class Solution { List list = new List(); public int solution(int k, int[,] dungeons) { int answer = -1; int size = dungeons.GetLength(0..

[자료구조] 순열(Permutation)개념 구현 C#

순열(Permutation) 순열이란 순서가 부여된 서로 다른 원소배열을 중복없이 순서에 맞게 나열하는 것이다. 예를들어 1,2,3 이란 배열을 순열한다면 아래처럼 된다. 1,2,3 1,3,2 2,1,3 2,3,1 3,1,2 3,2,1 순열을 구하는 기본적인 방법은 재귀를 통해 DEPTH의 위치와 각위치의 숫자를 스왑하여 재귀로 호출하고 다시 원복하는 것 이다. 재귀를 호출 할 때 DEPTH와 i가 같을 때는 원래위치도 순열 중 하나이기 때문에 그대로 진행한다. 종료시에는 DEPTH와 구하려는 길이가 같은 시점에서 재귀를 종료하면 된다. 소스코드 static void Main(string[] args) { int[] datas = new int[] { 1, 2, 3 }; Permutation(datas,..

[프로그래머스]Lv.2 주차 요금 계산 C#

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

[프로그래머스]Lv.2 두 큐 합 같게 만들기 C#

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

[프로그래머스]Lv.2 할인 행사 C#

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

※[프로그래머스]Lv.2 롤케이크 자르기C# (순차적으로 줄여나가기)

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

※[프로그래머스]Lv.2 귤 고르기C# (Dictionary.TryAdd 중복 카운터)

https://school.programmers.co.kr/learn/courses/30/lessons/138476 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드1 using System; using System.Collections.Generic; using System.Linq; public class Solution { public int solution(int k, int[] tangerine) { int answer = 0; var distinct = tangerine.GroupBy(g => g).Select(s => s.Count())..

※[프로그래머스]Lv.2 숫자 변환하기 C# (Hashset)

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

※[프로그래머스]Lv.2 뒤에 있는 큰 수 찾기 C# (시간복잡도오류, 스택)

https://school.programmers.co.kr/learn/courses/30/lessons/154539 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 뒤에있는 숫자를 구할 때는 스택을 사용하는게 편리하다. using System; using System.Collections.Generic; using System.Linq; public class Solution { public int[] solution(int[] numbers) { int[] answer = new int[numbers.Length]; Array.Fill(answe..