💬 문제
[코딩테스트 연습 - 오픈채팅방](https://school.programmers.co.kr/learn/courses/30/lessons/42888?language=python3)
💬 Idea
- uid와 nickname이 쌍을 이루는 dictionary를 만들어서 키값에 대한 닉네임이 바뀔 때마다 update를 해준다.
- 마지막에 배열을 한번 더 순회하면서 dictionary의 값에 해당하는 nickname으로 결과를 도출해준다.
💬 풀이
import Foundation
func solution(_ record:[String])->[String]{varuidDict:[String:String]=[:]varresult:[String]=[]foriin record {letrec= i.components(separatedBy:.whitespaces)ifrec[0]!="Leave"{uidDict[rec[1]]=rec[2]}}
record.forEach{letrec= $0.components(separatedBy:.whitespaces)ifrec[0]!="Change"{
result.append("\(uidDict[rec[1]]!)님이 "+(rec[0]=="Enter"?"들어왔습니다.":"나갔습니다."))}}return result
}소요시간 : 11분
💬 문제[코딩테스트 연습 - 오픈채팅방](https://school.programmers.co.kr/learn/courses/30/lessons/42888?language=python3)
💬 Idea💬 풀이소요시간: 11분