반응형
이 문제를 풀기 전에 아래 문제를 먼저 푸는 것을 추천한다.
백준 C# - 10808
백준 C# - 10808
using System; using System.Collections.Generic; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string word = Console.ReadLine(); int[] vs = new int[26]; foreach(char c in word) { vs[c - 'a']++; } for(int i = 0; i
code-piggy.tistory.com
using System;
using System.Linq;
namespace baek2
{
class Program
{
static void Main(string[] args)
{
string word = Console.ReadLine();
int[] vs = Enumerable.Repeat(-1, 26).ToArray();
int index = 0;
foreach (char c in word)
{
if (vs[c - 'a'] != -1)
{
index++;
continue;
}
vs[c - 'a'] = index;
index++;
}
for(int i = 0; i<vs.Length;i++)
{
Console.Write($"{vs[i]} ");
}
}
}
}
반응형
'코딩테스트 준비 > 백준 C#' 카테고리의 다른 글
백준 C# - 2743 (0) | 2023.10.27 |
---|---|
백준 C# - 10820 +)풀이 (0) | 2023.10.23 |
백준 C# - 10808 (0) | 2023.10.23 |
백준 C# - 1918 +) 풀이 (0) | 2023.10.20 |
백준 C# - 1935 +) 풀이 (0) | 2023.10.20 |
댓글