class Solution {
public int[] solution(String[] keyinput, int[] board) {
int[] answer = {};
answer = new int[2];
int[] coordinate = new int[2];
coordinate[0] = 0;
coordinate[1] = 0;
for (int i = 0 ; i <keyinput.length ; i++){
if(keyinput[i].equals("up")){
if(coordinate[1]!=board[1]/2){
++coordinate[1];
}
}else if(keyinput[i].equals("down")){
if(coordinate[1]!=-board[1]/2){
--coordinate[1];
}
}else if(keyinput[i].equals("left")){
if(coordinate[0]!=-board[0]/2){
--coordinate[0];
}
}else if(keyinput[i].equals("right")){
if(coordinate[0]!=board[0]/2){
++coordinate[0];
}
}
}
answer[0] = coordinate[0];
answer[1] = coordinate[1];
return answer;
}
}