public String simplifyPath(String path) {
        Stack<String> stack = new Stack<String>();
        for(String command : path.split("/")){
            if(command.equals(".") || command.equals("")){
                continue;
            }else if(command.equals("..")){
                if(!stack.isEmpty()) stack.pop();
            }else{
                stack.push("/" + command);
            }
        }

        if(stack.isEmpty()){
            return "/";
        }

        StringBuilder result = new StringBuilder();
        while(!stack.isEmpty()){
            result.insert(0, stack.pop());
        }
        return result.toString();
    }