当前位置: 首页 > news >正文

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:输入一个当前不存在的 文件夹路径 ,你需要根据路径名创建一个新的文件夹。

如果有上层文件夹路径不存在,那么你也应该将它们全部创建。

这个函数的返回类型为 void 。

addContentToFile:输入字符串形式的 文件路径 和 文件内容 。

如果文件不存在,你需要创建包含给定文件内容的文件。

如果文件已经存在,那么你需要将给定的文件内容 追加 在原本内容的后面。

这个函数的返回类型为 void 。

readContentFromFile:输入 文件路径 ,以字符串形式返回该文件的 内容 。

示例

http://www.lryc.cn/news/175014.html

相关文章:

  • Haproxy负载均衡群集
  • 什么是面包屑导航?
  • VS2019创建GIt仓库时剔除文件或目录
  • 计算机等级考试—信息安全三级真题六
  • vue循环滚动字幕
  • 扩展pytest接口自动化框架-MS数据解析功能
  • docker容器安装MongoDB数据库
  • Python机器学习实战-特征重要性分析方法(3):迭代删除法:Leave-one-out(附源码和实现效果)
  • Go的error接口
  • RabbitMQ 集群 - 普通集群、镜像集群、仲裁队列
  • 高项新版教程(第四版)解读+学习指导
  • 【Debian】Debian10.0.0安装选项问答
  • 【基于React-Native做位置信息获取,并展示出来】
  • ansible安装、点对点Ad-Hoc、模块、剧本Playbook
  • Ceph入门到精通-ceph pool 删除导致 misplaced 的原因
  • 计算机组成原理课程设计
  • 《从菜鸟到大师之路 MySQL 篇》
  • 使用qt完善对话框功能
  • Day 03 python学习笔记
  • 优化类问题概述
  • 第一个 Go 程序“hello,world“ 与 main 函数
  • MySQL缓冲池Buffer Pool
  • springboot实现发送邮箱验证码
  • ESP8266使用记录(三)
  • 基于微信小程序的在线视频课程学习平台设计与实现(源码+lw+部署文档+讲解等)
  • CloudCompare 二次开发(15)——点云添加高斯噪声
  • 一波免费、好用的API接口分享
  • Android App ~ LiveData
  • 全球第4大操作系统(鸿蒙)的软件后缀.hap
  • 算法练习第六十四天