题解 | #迷路的牛牛#

迷路的牛牛

http://www.nowcoder.com/practice/fc72d3493d7e4be883e931d507352a4a

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int N = sc.nextInt();
            char[] arr = sc.next().toCharArray();
            HashMap<String, String> map = new HashMap<>();
            map.put("NL", "W");
            map.put("EL", "N");
            map.put("SL", "E");
            map.put("WL", "S");
            map.put("NR", "E");
            map.put("ER", "S");
            map.put("SR", "W");
            map.put("WR", "N");
            String now = "N";
            for(int i = 0; i < N; i++) {
                now = map.get(now + arr[i]);
            }
            System.out.println(now);
        }
    }
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务