public static String simplifyPath(String path) {//AC
        String[] tokens = path.split("/");
        System.out.println("TOKENS START");
        for (int i = 0; i < tokens.length; ++i) {
        	System.out.println(tokens[i]);
        }
        System.out.println("TOKENS end");

        java.util.LinkedList<String> stk = new java.util.LinkedList<String>();
        for (int i = 0; i < tokens.length; ++i) {
        	if (tokens[i].length() == 0 || tokens[i].equals(".")) {
        		continue;
        	}
        	else if (tokens[i].equals("..")) {
        		if (!stk.isEmpty()) {
        			stk.removeLast();
        		}
        		else {
        			//return "/";
        		}
        	}
        	else {
        		stk.add(tokens[i]);
        	}
        }
        if (stk.isEmpty()) {
        	return "/";
        }
        StringBuilder s = new StringBuilder();
        while (!stk.isEmpty()) {
        	s.append("/");
        	s.append(stk.remove());
        }
        return s.toString();
    }