Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created May 22, 2020 07:59
Show Gist options
  • Save DongguemYoo/95b7cf630819aed66c08aed66bc42279 to your computer and use it in GitHub Desktop.
Save DongguemYoo/95b7cf630819aed66c08aed66bc42279 to your computer and use it in GitHub Desktop.
코딩테스트 연습 스킬트리.cs
//string.Replace
//Regex.Replace
//왜 안되는지 모르겠음 나중에 다시보자~
using System;
using System.Linq;
using System.Text.RegularExpressions;
public class Solution {
public int solution(string skill, string[] skill_trees)
{
int answer = 0;
bool isable = true;
for (int j = 0; j < skill_trees.Length; j++)
{
for (int i = 0; i < skill.Length; i++)
{
skill_trees[j] = skill_trees[j].Replace(Convert.ToChar(skill[i]), Convert.ToChar(i.ToString()));
}
//문자는 확인할 필요없이 인덱스가 0부터 가는지 확인하기위해 다 삭제
//skill_trees[j] = Regex.Replace(skill_trees[j], @"\D", "");
skill_trees[j] = Regex.Replace(skill_trees[j], @"\D", "");
//기본적으로 1개이상의 스킬트리중의 스킬을 보유하고있는 스킬트리이다
//0,1,2, 순서로 가지 않는다면 탈락이다
for (int x = 0; x < skill_trees[j].Length; x++)
{
if (Convert.ToChar(x.ToString()) != skill_trees[j][x])
{
isable = false;
break;
}
isable = true;
}
//스킬트리에 없는 스킬만 있다면 가능이라고 보고 추가
if (skill_trees[j].Length == 0)
{
isable = true;
}
if (isable)
answer++;
}
return answer;
}
}
정확성 92.6
합계 92.6/100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment