141. 중복된 문자 제거

김해준's avatar
Dec 28, 2025
141. 중복된 문자 제거

사용언어 : Java

문제
notion image
풀이
/* answer = "" my_string = "people" my_string의 첫글자부터 차례대로 떼어와서 answer에 해당 글자가 있는지 검사하고 있으면 패스 없으면 넣기 이러면 될거같은데 */ class Solution { public String solution(String my_string) { String answer = ""; for(int i = 0 ; i < my_string.length(); i++) { String temp = ""; temp += my_string.charAt(i); if(!answer.contains(temp)) answer += temp; } return answer; } }
notion image
Share article