-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path오픈채팅방.swift
More file actions
41 lines (35 loc) · 977 Bytes
/
오픈채팅방.swift
File metadata and controls
41 lines (35 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// 오픈채팅방.swift
//
//
// Created by chihoooon on 2022/01/24.
//
import Foundation
func solution(_ record:[String]) -> [String] {
var result: [String] = []
var user: [String: String] = [:]
var actions: [String] = []
var uids: [String] = []
record.forEach {
let userInfo = $0.components(separatedBy: " ")
let action = userInfo[0]
let uid = userInfo[1]
actions.append(action)
uids.append(uid)
if action != "Leave" {
let nickname = userInfo[2]
user.updateValue(nickname, forKey: uid)
}
}
for i in 0..<actions.count {
switch actions[i] {
case "Enter":
result.append("\(user[uids[i]]!)님이 들어왔습니다.")
case "Leave":
result.append("\(user[uids[i]]!)님이 나갔습니다.")
default:
break
}
}
return result
}