코딩테스트_c#/프로그래머스
프로그래머스 ) 코딩 기초 트레이닝 - 전국 대회 선발 고사_c#
노년인생
2024. 2. 13. 20:42
728x90
반응형
전국 대회 선발 고사 문제
내 코드
using System;
using System.Collections.Generic;
using System.Linq;
public class Solution {
public int solution(int[] rank, bool[] attendance) {
int answer = 0;
Dictionary<int, int> dic = new Dictionary<int, int>();
for (int i = 0; i < rank.Length; i++)
{
if (attendance[i])
dic.Add(rank[i], i);
}
List<int> list = dic.Keys.ToList();
list.Sort();
answer = dic[list[0]] * 10000 + dic[list[1]] * 100 + dic[list[2]];
return answer;
}
}
728x90
반응형