728x90
SMALL

C#

 

 

 

using System;
using System.Linq;

public class Solution {
    public string solution(string my_string) {
        
        string answer = string.Concat(my_string.Distinct());
        return answer;
    }
}

 

 

 

 

파이썬

///

 

 

 

def solution(my_string):
    answer = ''
    for i in my_string:
        if i not in answer:
            answer+=i
    return answer

 

 

////

 

 

 

def solution(my_string):
    return ''.join(dict.fromkeys(my_string))

 

 

 

자바

/////

 

 

import java.util.*;
import java.util.stream.Collectors;

class Solution {
    public String solution(String myString) {
        return Arrays.stream(myString.split("")).distinct().collect(Collectors.joining());
    }
}

 

 

//////

 

 

import java.util.*;
class Solution {
    public String solution(String my_string) {
        String[] answer = my_string.split("");
        Set<String> set = new LinkedHashSet<String>(Arrays.asList(answer));

        return String.join("", set);
    }
}

 

728x90

설정

트랙백

댓글