코딩공부 221

[프로그래머스]Lv.2 최댓값과 최솟값 C#(문자배열 to 정수배열 변환 링큐)

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

[프로그래머스]Lv.2 다음 큰 숫자 C#

https://school.programmers.co.kr/learn/courses/30/lessons/12911 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드1(시간복잡도 오류) using System; using System.Linq; class Solution { public int solution(int n) { int nBinary = Convert.ToString(n, 2).Where(s=>s == '1').Count(); while (true) { int nextBinary = Convert.ToString(++n, 2).Where(..

[프로그래머스]Lv.2 최솟값 만들기 C#

https://school.programmers.co.kr/learn/courses/30/lessons/12941 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; using System.Linq; public class Solution { public int solution(int[] A, int[] B) { int answer = 0; int[] minSort = A.OrderBy(x => x).ToArray(); int[] maxSort = B.OrderByDescending(x => x).ToArray(); for (..

[프로그래머스]Lv.2 올바른 괄호 C#

https://school.programmers.co.kr/learn/courses/30/lessons/12909 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 소스코드 using System; public class Solution { public bool solution(string s) { int count = 0; if (s[0] == ')') return false; foreach (char c in s) { if (c == '(') count++; else count--; if (count < 0) return false; } return co..

[프로그래머스]Lv.2 게임 맵 최단거리 C#(BFS)

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

[프로그래머스]Lv.2 영어 끝말잇기 C#

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

[프로그래머스]Lv.2 다리를 지나는 트럭C#

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

[프로그래머스]Lv.2 주식가격C#

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

[프로그래머스]Lv.2 기능개발C#

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

※[프로그래머스]Lv.2 가장 큰 수C#(문자열 CompareTo 정렬, 시간복잡도 오류)

https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 처음에 순열을 통하여 접근하는 방법을 생각했으나 시간복잡도 오류가 발생하였다. 문자열 비교를 통해 정렬 하여 문제를 해결하였다. 소스코드1(시간복잡도 오류) using System; using System.Collections.Generic; using System.Linq; using System.Text; public class Solution { List list = new List(); p..