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
- 2D슈팅게임
- 일시정지
- Transform
- CSharp #자료구조
- 플레이어 방향전환
- 오브젝트 풀링
- Ainimation Blending
- Object Pooling
- Parallax
- 유니티
- Unity
- raycasting
- 스크롤링
- Hp바
- rigidbody
- rotation
- LayerMark
- 플레이어 이동
- joystick
- 패럴렉스
- Prefabs
- Animation State Machine
- apk
- Blend Type
- Hpbar
- Object Poling
- 프리팹
- Scrooling
- raycast
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.1 달리기 경주 본문
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/178871
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 정답코드 및 핵심 아이디어, 유의사항
- 딕셔너리의 키 (플레이어 이름), 값 (플레이어 순위)
using System;
using System.Collections.Generic;
public class Solution
{
public string[] solution(string[] players, string[] callings)
{
Dictionary<string, int> dict = new Dictionary<string, int>();
for (int i = 0; i < players.Length; i++)
dict.Add(players[i], i); // 키 값에 대한 순위
for (int i = 0; i < callings.Length; i++)
{
int num = dict[callings[i]]--; // 현재 순위 + 1
string str = players[num - 1]; // 추월 당하는 플레이어
players[num - 1] = players[num];
players[num] = str;
dict[str]++;
}
return players;
}
}
728x90
'Programmers - C# > CodingTest Lv.1' 카테고리의 다른 글
[프로그래머스 C#] Lv.1 대충 만든 자판 (0) | 2023.08.30 |
---|---|
[프로그래머스 C#] Lv.1 둘만의 암호 (0) | 2023.08.23 |
[프로그래머스 C#] Lv.1 성격 유형 검사하기 (0) | 2023.08.22 |
[프로그래머스 C#] Lv.1 숫자 짝꿍 (0) | 2023.08.18 |
[프로그래머스 C#] Lv.1 공원 산책 (0) | 2023.08.18 |