作者: 负雪明烛 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…
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…
就是看哪个文件的绝对路径最长,不是看最深,是看最长,跟文件夹名,文件名都有关. \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)…
[LeetCode]522. Longest Uncommon Subsequence II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/longest-uncommon-subsequence-ii/description/ 题目描述: Given a list of strings, you…
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-directory …