강의로 돌아가기
서주형

c# 3,4,6,10,12 실패

도대체 왜 실패가 뜨는지 모르겠습니다
쓰여진글도 다 읽어봤고 이런저런 케이서 넣어서 해도 다 잘 되는데요 ㅠㅠㅠ

실패되는 테스트 케이스 하나만 조언 부탁 드려요

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class NewBaseType
{
public string[] solution(string[] sTrs, int nUm)
{
// 받아온 어레이 리스트로 바꾸고 먼저 소팅 (마지막조건위함)
List sTrslist = sTrs.ToList();
sTrs
list.Sort();
//정렬기준 생성 (기준만 생성하고 정렬은 안된상태)
List gIjun = new List();
for(int i = 0 ; i < sTrslist.Count; i++)
{
string gIjun
eachstr = sTrslist[i][nUm].ToString();
gIjun.Add(string.Format("{0}{1}", gIjuneachstr, i)); //////string.Format 배움 ㅎㅎ
}
//정렬기준과 정렬대상 딕셔너리에 페어링
Dictionary dIction = new Dictionary();
for (int i = 0; i aNswerlist = new List();
for (int i= 0; i< gIjun.Count; i++)
{
aNswer
list.Add(dIction[gIjun[i]]);
}
string[] answer = aNswer_list.ToArray();

return answer;
}
}

작성중인 코드―Solution.cs
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
32
33
34
35
36
37
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public string[] solution(string[] sTrs, int nUm)
    {
        // 받아온 어레이 리스트로 바꾸고 먼저 소팅 (마지막조건위함)
        List<string> sTrs_list = sTrs.ToList();
        sTrs_list.Sort();
        //정렬기준 생성  (기준만 생성하고 정렬은 안된상태)
        List<string> gIjun = new List<string>();
        for(int i = 0 ; i < sTrs_list.Count; i++)
        {
            string gIjun_each_str = sTrs_list[i][nUm].ToString();
            gIjun.Add(string.Format("{0}{1}", gIjun_each_str, i));             //////string.Format 배움 ㅎㅎ
        }
        //정렬기준과 정렬대상 딕셔너리에 페어링
        Dictionary<string, string> dIction = new Dictionary<string, string>();
        for (int i = 0; i <sTrs_list.Count; i++)
        {
            dIction.Add(gIjun[i], sTrs_list[i]);
        }
        //기준만 소팅
        gIjun.Sort();
        //소팅된 기준에 맞는 순서로 딕셔너리에서 자료 불러옴
        List<string> aNswer_list = new List<string>();
        for (int i= 0; i< gIjun.Count; i++)
        {
            aNswer_list.Add(dIction[gIjun[i]]);
        }
        string[] answer = aNswer_list.ToArray();             
        return answer;
    }
}
0 개의 답변
답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다. 마크다운 가이드 를 참고하세요.