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
- Lv2
- 유니티
- dfs
- 2870번
- 백준 c++ 2468번
- Beakjoon
- 플레이어 이동
- Algorithm
- 2870번 수학숙제
- 수학숙제
- 백준 17070번 c++
- 백준
- 2468 c++
- 백준 1103번 c++
- 2870번 수학숙제 c++
- 백준 2870번
- 17070번
- 코딩테스트
- 백준 c++ 2870번
- 백준 17070번
- C#
- 코테
- c++
- Unity
- 오브젝트 풀링
- 2870번 c++
- 프로그래머스
- Lv.3
- 백준 1103번
- 백준 1103번 게임
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.1 달리기 경주 본문
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;
}
}
'CodingTest > Programmers 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 |