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
- Object Poling
- Hp바
- raycasting
- Unity
- Animation State Machine
- joystick
- 일시정지
- 유니티
- 플레이어 방향전환
- Object Pooling
- rotation
- Prefabs
- Scrooling
- Parallax
- Blend Type
- 오브젝트 풀링
- LayerMark
- rigidbody
- Ainimation Blending
- 2D슈팅게임
- 프리팹
- raycast
- 패럴렉스
- apk
- Transform
- 스크롤링
- CSharp #자료구조
- Hpbar
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 할인 행사 본문
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/131127
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 정답코드 및 핵심 아이디어, 유의사항
원하는 제품을 모두 할인상품으로 구매할 수 있는 날의 숫자를 구하는 문제
- 원하는 제품들의 개수의 총합과 연속으로 일치해야 하는 날짜의 수가 같으므로, 모든 제품을 10일의 기간동안 원하는 개수만큼 딱 맞게 구매해야 함
- Dictionary<key, value> 활용 ( key : 원하는 제품, value : 원하는 제품 수량 )
https://godgjwnsgur7.tistory.com/46
[C#] 자료구조 ( 제네릭 컬렉션 )
자료구조(Data Structure)란? 데이터를 효율적으로 접근하고 조작할 수 있게 데이터 구조를 만들어 관리하는 것 - Collections은 C#에서 지원하는 자료구조 클래스 using System.Collections.Generic; 제네릭 컬렉
godgjwnsgur7.tistory.com
주석참조
using System;
using System.Collections.Generic;
public class Solution
{
public int solution(string[] want, int[] number, string[] discount)
{
int answer = 0;
// 과일이름 want, 과일 수 number를 담을 딕셔너리
Dictionary<string, int> dict = new Dictionary<string, int>();
// 0번 인덱스부터 10개씩 확인
for (int i = 0; i < discount.Length - 9; i++)
{
// 딕셔너리 값 초기화
for (int j = 0; j < want.Length; j++)
dict.Add(want[j], number[j]);
// 원하는 과일 구매
for (int j = i; j < i + 10; j++)
if (dict.ContainsKey(discount[j]))
dict[discount[j]]--;
// 원하는 모든 과일을 다 구매헀는지 판단
int maxValue = 0;
foreach (int dictValue in dict.Values)
if (dictValue > maxValue)
maxValue = dictValue;
// 원하는 모든 과일을 구매했다면 10일 연속 일치
if (maxValue == 0)
answer++;
dict.Clear();
}
return answer;
}
}
728x90
'Programmers - C# > CodingTest Lv.2' 카테고리의 다른 글
[프로그래머스 C#] Lv.2 다리를 지나는 트럭 (0) | 2023.11.14 |
---|---|
[프로그래머스 C#] Lv.2 두 큐 합 같게 만들기 (0) | 2023.11.13 |
[프로그래머스 C#] Lv.2 요격 시스템 (0) | 2023.11.09 |
[프로그래머스 C#] Lv.2 두 원 사이의 정수 쌍 (0) | 2023.11.07 |
[프로그래머스 C#] Lv.2 행렬 테두리 회전하기 (2) | 2023.11.03 |