leetcode 388.Lonest Absolute File Path】的更多相关文章

要求寻找的是最长的长度的,那么考虑文件夹和文件的存在的不同形式的,利用当前所存在的层数和对应的长度之间做一个映射关系的并且用于计算总的长度关系的. class Solution { public: int lengthLongestPath(string input) { ,level=; map<,}}; int n=input.size(); ;i<n;i++){ int start=i; while(i<n && input[i]!='\n'&&in…
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory …
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/longest-absolute-file-path/description/ 题目描述: Suppose we abstract our file system by a string in the following manner: The string "dir\n\…
题目如下: Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext"represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-direc…
就是看哪个文件的绝对路径最长,不是看最深,是看最长,跟文件夹名,文件名都有关. \n表示一波,可能存在一个文件,可能只有文件夹,但是我们需要检测. 之后的\t表示层数. 思路是如果当前层数多余已经有的层数说明是在go deeper,就继续,否则就要回到他属于的父目录,这个性质用STACK来实现再好不过.. 然后一开始没注意求的是最大长度,所以想的是往里PUSH文件夹的名字,其实因为只需要长度,光PUSH文件夹名字的长度就行了.. 用split("\n")来分,注意\t \n是他妈一个字…
详见:https://leetcode.com/problems/longest-absolute-file-path/description/ C++: class Solution { public: int lengthLongestPath(string input) { int res = 0, n = input.size(), level = 0; unordered_map<int, int> m {{0, 0}}; for (int i = 0; i < n; ++i)…
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory …
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory…
问题描述 Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-direc…
Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory …