[프로그래머스 | C# | Lv.0] 한 번만 등장한 문자

728x90

https://school.programmers.co.kr/learn/courses/30/lessons/120896

📝 나의 풀이

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

public class Solution {
    public string solution(string s) {
        string answer = "";
        
        char[] arr = s.ToCharArray();
        Array.Sort(arr);
        
        List<int> tmp = new List<int>();
        
        for(int i=0; i<s.Length; i++){
            if(s.Count(f => (f == arr[i])).Equals(1)){
                tmp.Add(i);
            }
        }
        
        for(int i=0; i<tmp.Count; i++){
            answer += arr[tmp[i]].ToString();
        }

        return answer;
    }
}
728x90