알고리즘 문제풀이/프로그래머스
[프로그래머스 2019 KAKAO BLIND RECRUITMENT] 오픈채팅방
m2162003
2021. 2. 21. 00:44
programmers.co.kr/learn/courses/30/lessons/42888
코딩테스트 연습 - 오픈채팅방
오픈채팅방 카카오톡 오픈채팅방에서는 친구가 아닌 사람들과 대화를 할 수 있는데, 본래 닉네임이 아닌 가상의 닉네임을 사용하여 채팅방에 들어갈 수 있다. 신입사원인 김크루는 카카오톡 오
programmers.co.kr
여윽시 문자열은 파이썬이다.
딕셔너리만 사용한다면 어렵지 않은 문제였다.
def solution(record):
answer = []
users_dict = {}
for r in record:
info = r.split(' ')
if info[0] == 'Enter':
users_dict[info[1]] = info[2]
elif info[0] == 'Change':
users_dict[info[1]] = info[2]
for r in record:
info = r.split(' ')
if info[0] == 'Enter':
answer.append(f'{users_dict[info[1]]}님이 들어왔습니다.')
elif info[0] == 'Leave':
answer.append(f'{users_dict[info[1]]}님이 나갔습니다.')
return answer