• leetcode 558 设计内存文件系统


    题目

    Design an in-memory file system to simulate the following functions:

    ls: Given a path in string format. If it is a file path, return a list that only contains this file's name.

    If it is a directory path, return the list of file and directory namesin this directory. Your output (file and directory names together) should inlexicographic order.

    mkdir: Given adirectory paththat does not exist, you should make a new directory according to the path.

    If the middle directories in the path don't exist either, you should create them as well. This function has void return type.

    addContentToFile: Given afile pathandfile contentin string format. If the file doesn't exist, you need to create that file containing given content.

    If the file already exists, you need toappendgiven content to original content. This function has void return type.

    readContentFromFile: Given afile path, return itscontentin string format.

    设计一个内存文件系统,模拟以下功能:

    ls:以字符串的格式输入一个路径。

    如果它是一个文件的路径,那么函数返回一个列表,仅包含这个文件的名字。

    如果它是一个文件夹的的路径,那么返回该 文件夹内 的所有文件和子文件夹的名字。

    你的返回结果(包括文件和子文件夹)应该按字典序排列。

    mkdir:输入一个当前不存在的 文件夹路径 ,你需要根据路径名创建一个新的文件夹。

  • 相关阅读:
    Redis从入门到放弃(8):哨兵模式
    python对象持久化shelve模块
    机器学习(19)---XGBoost入门
    367. 有效的完全平方数
    webpack5 之 css与js相关
    flutter 自定义加载中间页 loading 菊花组件的封装
    Qt学习11 Qt 中的字符串类
    猜数字1~100
    Java学习day07:面向对象三大特性之一:封装
    html->课程表
  • 原文地址:https://blog.csdn.net/as4589sd/article/details/133255814