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 |
Tags
- Beakjoon
- 수학숙제
- Algorithm
- 코테
- 프로그래머스
- C#
- 2870번 c++
- 2870번 수학숙제
- dfs
- 백준 c++ 2870번
- c++
- 2870번 수학숙제 c++
- 백준 17070번 c++
- 2870번
- 코딩테스트
- 오브젝트 풀링
- 플레이어 이동
- 2468 c++
- 백준 1103번
- Unity
- 백준 17070번
- 백준
- 17070번
- 백준 1103번 c++
- 백준 1103번 게임
- 유니티
- 백준 c++ 2468번
- Lv2
- 백준 2870번
- Lv.3
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 주식가격 본문
https://school.programmers.co.kr/learn/courses/30/lessons/42584
1. 정답코드 및 핵심 아이디어, 유의사항
- 스택/큐 문제라고 분류되어 있다고, 스택/큐 로만 해결하려고 하지 않아도 됨
+ List가 편해서 List를 사용했는데, Array가 더 빠름
using System;
using System.Collections.Generic;
public class Solution
{
public int[] solution(int[] prices)
{
List<int> list = new List<int>();
for (int i = 0; i < prices.Length; i++)
{
int num = 0;
// 몇 초 뒤에 떨어지는지 체크
for (int j = i + 1; j < prices.Length; j++)
{
num++;
if (prices[i] > prices[j])
break;
}
list.Add(num);
}
return list.ToArray();
}
}
'CodingTest > Programmers Lv.2' 카테고리의 다른 글
[프로그래머스 C#] Lv.2 귤 고르기 (0) | 2023.08.25 |
---|---|
[프로그래머스 C#] Lv.2 k진수에서 소수 개수 구하기 (0) | 2023.08.25 |
[프로그래머스 C#] Lv.2 호텔 대실 (0) | 2023.08.23 |
[프로그래머스 C#] Lv.2 소수 찾기 (2) | 2023.08.23 |
[프로그래머스 C#] Lv.2 스킬트리 (0) | 2023.08.23 |