분류 전체보기 504

[프로그래머스]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..

[프로그래머스]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..

[C++] 스마트 포인터 (shared_ptr, weak_ptr, unique_ptr)

스마트 포인터인동적 메모리를 할당하면 스택에 주소가 입력되고 힙 메모리에 데이터가 입력되게 된다. 이렇게 동적으로 할당된 메모리는 사용 후 반드시 직접 해제를 해줘야 하는데 더 이상 사용하지 않는 메모리가 메모리를 점유하는 메모리 누수 현상이 일어나기 때문이다. 하지만 직접메모리를 해제하면 메모리관리를 하면서 문제가 발생할 수 있다. 예를 들어 아래와 같이 다른 객체의 포인터를 참조하고 있는 객체가 존재하고 참조하고 있는 객체의  힙 메모리가 해제된 상태로 해당 객체를 접근하게 되면 이미 메모리가 해제된 상태이기 때문에 이미 해제된 메모리에 접근을 하는 문제가 발생하며 해당 오류가 발생하지 않기 위해서는 예외처리도 많이 들어가고 구조를 짜기에도 어려움이 많이 존재한다. 때문에 C++에서는 스파트 포인터는..

VisualStudio/C++ 2023.07.31

※[프로그래머스]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..