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 (fil...
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 (f...
1classFileSystem {2privateclassFileNode {3privateTreeMap<String, FileNode>children;4privateStringBuilder file;5privateString name;67publicFileNode(String name) {8children =newTreeMap<>();9file =newStringBuilder();10this.name =name;11}1213publicString getContent() {14returnfile.toString();15}1617...
String > files = new HashMap < > (); } Dir root; public FileSystem() { root = new Dir(); } public List < String > ls(String path) { Dir t = root; List < String > files = new ArrayList < > (); if (!path
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 (...
提交记录 代码 9 1 2 › ["FileSystem","ls","mkdir","addContentToFile","ls","readContentFromFile"] [[],["/"],["/a/b/c"],["/a/b/c/d","hello"],["/"],["/a/b/c/d"]] Source 该题目是 Plus 会员专享题 感谢使用力扣!您需要升级为 Plus 会员来解锁该题目 ...
588 Design In-Memory File System 🔒 Hard NaN NaN NaN NaN 591 Tag Validator Hard NaN NaN NaN NaN 592 Fraction Addition and Subtraction Medium NaN NaN NaN NaN 593 Valid Square Medium NaN NaN NaN NaN 594 Longest Harmonious Subsequence Easy NaN NaN NaN NaN 598 Range Addition II Easy NaN NaN...
588 Design In-Memory File System design-in-memory-file-system.cc 587 Erect the Fence erect-the-fence.cc 583 Delete Operation for Two Strings delete-operation-for-two-strings.cc 582 Kill Process kill-process.cc 581 Shortest Unsorted Continuous Subarray shortest-unsorted-continuous-subarray.cc 575 ...
If the file content is very large (GB level), how will you modify your solution? If you can only read the file by 1kb each time, how will you modify your solution? What is the time complexity of your modified solution? What is the most time-consuming part and memory consuming part of...
421.Maximum-XOR-of-Two-Numbers-in-an-Array (H) 648.Replace-Words (H) 588.Design-In-Memory-File-System (H-) 677.Map-Sum-Pairs (M) 676.Implement-Magic-Dictionary (H-) 212.Word-Search-II (H-) 745.Prefix-and-Suffix-Search (H-) 1268.Search-Suggestions-System (H-) 1032. Stream of...