import java.util.*;
class Solution {
public String[] solution(String[] record) {
String[] answer = {};
List<String> answer_list = new ArrayList<String>();
Map<String, String> id_nickname = new HashMap<String, String>();
String[] s = null;
for (int i = 0; i < record.length; i++) {
s = new String[3];
s = record[i].split(" ");
// record중 들어오거나 변경하는게 있으면 id에 있는 닉네임을 변경해줌.
if( s[0].equals("Enter") || s[0].equals("Change")) {
id_nickname.put(s[1], s[2]);
}
}
for (int i = 0; i < record.length; i++) {
s = new String[3];
s = record[i].split(" ");
if( s[0].equals("Enter") ) {
answer_list.add( id_nickname.get(s[1]) + "님이 들어왔습니다.");
} else if( s[0].equals("Leave") ) { // 나갈때
answer_list.add( id_nickname.get(s[1]) + "님이 나갔습니다.");
}
}
answer = answer_list.toArray(new String[0]);
return answer;
}
}