public String simplifyPath(String path) {
        String[] str = path.split("/");
        Deque<String> queue = new LinkedList<String>();
        for (int i = 0; i < str.length; ++i) {
            if (str[i].equals("") || str[i].equals("."))
                continue;
            else if (str[i].equals("..")) {
                if (!queue.isEmpty())
                    queue.removeLast();
            } else {
                queue.offerLast(str[i]);
            }
        }
        if (queue.isEmpty())
            return "/";
        String res = "";
        while (!queue.isEmpty()) {
            res += ("/" + queue.removeFirst());
        }
        return res;
    }