250x250
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 | 29 | 30 | 31 |
Tags
- Vector3
- Parallax
- Ainimation Blending
- joystick
- Scrooling
- Animation State Machine
- CSharp #자료구조
- 플레이어 이동
- Object Pooling
- 패럴렉스
- 플레이어 방향전환
- 스크롤링
- raycasting
- 프리팹
- rotation
- Transform
- Object Poling
- rigidbody
- LayerMark
- 유니티
- Blend Type
- apk
- Unity
- Hp바
- 2D슈팅게임
- Prefabs
- 일시정지
- Hpbar
- raycast
- 오브젝트 풀링
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 주식가격 본문
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/42584
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
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();
}
}
728x90
'Programmers - C# > CodingTest Lv.2' 카테고리의 다른 글
[프로그래머스 C#] Lv.2 k진수에서 소수 개수 구하기 (0) | 2023.08.25 |
---|---|
[프로그래머스 C#] Lv.2 호텔 대실 (0) | 2023.08.23 |
[프로그래머스 C#] Lv.2 소수 찾기 (1) | 2023.08.23 |
[프로그래머스 C#] Lv.2 스킬트리 (0) | 2023.08.23 |
[프로그래머스 C#] Lv.2 마법의 엘리베이터 (0) | 2023.08.18 |