From 90c28c3e8a1eaa14cd94fdfba7dc86ceed57ca0d Mon Sep 17 00:00:00 2001 From: heeheejj Date: Sun, 3 Dec 2023 01:34:14 +0900 Subject: [PATCH] =?UTF-8?q?Week28=20PRG=20121683=20=EC=99=B8=ED=86=A8?= =?UTF-8?q?=EC=9D=B4=20=EC=95=8C=ED=8C=8C=EB=B2=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4_\354\225\214\355\214\214\353\262\263.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "heeheej/week28/PRG_121683_\354\231\270\355\206\250\354\235\264_\354\225\214\355\214\214\353\262\263.py" diff --git "a/heeheej/week28/PRG_121683_\354\231\270\355\206\250\354\235\264_\354\225\214\355\214\214\353\262\263.py" "b/heeheej/week28/PRG_121683_\354\231\270\355\206\250\354\235\264_\354\225\214\355\214\214\353\262\263.py" new file mode 100644 index 0000000..5f0625e --- /dev/null +++ "b/heeheej/week28/PRG_121683_\354\231\270\355\206\250\354\235\264_\354\225\214\355\214\214\353\262\263.py" @@ -0,0 +1,23 @@ +# PCCP 모의고사 1 1번 외톨이 알파벳 +# 구현 + +def solution(input_string): + answer = '' + once = [] # 한번 이상 나타난 알파벳 + arr = [] # 외톨이 알파벳 + last_char = "-" + for x in input_string: + if x not in once: # 처음 나온 알파벳이면 + once.append(x) + elif last_char != x and x not in arr: + # 두번 이상 나온 알파벳인데, + # 앞 덩어리와 분리되어있고 + # 외톨이 알파벳 리스트에도 안들어있는 경우 외톨이 알파벳에 추가 + arr.append(x) + last_char = x + if arr: + arr.sort() # 알파벳순으로 정렬 + answer = ''.join(arr) + else: + answer = "N" + return answer \ No newline at end of file