Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main{
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String s = scan.next();
- int[] arr = new int[4];
- arr[0] = s.indexOf('N');
- arr[1] = s.indexOf('S');
- arr[2] = s.indexOf('E');
- arr[3] = s.indexOf('W');
- if((arr[0] >= 0 && arr[1] >= 0 && arr[2] >= 0 && arr[3] >= 0) ||
- (arr[0] >= 0 && arr[1] >= 0 && arr[2] == -1 && arr[3] == -1) ||
- (arr[0] == -1 && arr[1] == -1 && arr[2] >= 0 && arr[3] >= 0)) {
- System.out.println("Yes");
- }
- else {
- System.out.println("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement