[Leetcode] 588. Design In-Memory File System 解题报告

设计一个内存中的文件系统,实现ls、mkdir、addContentToFile和readContentFromFile四个功能。ls返回路径下的文件或目录名,mkdir创建路径,addContentToFile追加文件内容,readContentFromFile读取文件内容。解决方案使用字典树数据结构,每个节点表示文件或目录,通过递归处理路径完成操作。
摘要由CSDN通过智能技术生成

题目

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 names in this directory. Your output (file and directory names together) should in lexicographic order.

mkdir: Given a directory path that 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值