You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we were to write this representation in code, it will look like this:
16
+
`"dir\tsubdir1\t\tfile1.ext\t\tsubsubdir1\tsubdir2\t\tsubsubdir2\t\t\tfile2.ext"`. Note that the `'
28
17
'` and `'\t'` are the new-line and tab characters.
29
18
30
19
Every file and directory has a unique **absolute path** in the file system, which is the order of directories that must be opened to reach the file/directory itself, all concatenated by `'/'s`. Using the above example, the **absolute path** to `file2.ext` is `"dir/subdir2/subsubdir2/file2.ext"`. Each directory name consists of letters, digits, and/or spaces. Each file name is of the form `name.extension`, where `name` and `extension` consist of letters, digits, and/or spaces.
31
20
32
21
Given a string `input` representing the file system in the explained format, return _the length of the **longest absolute path** to a **file** in the abstracted file system_. If there is no file in the system, return `0`.
33
22
23
+
**Note** that the testcases are generated such that the file system is valid and no file or directory name has length 0.
**Explanation:** We have two files: "dir/subdir1/file1.ext" of length 21 "dir/subdir2/subsubdir2/file2.ext" of length 32. We return 32 since it is the longest absolute path to a file.
43
+
**Explanation:** We have two files:
53
44
54
-
**Example 3:**
45
+
"dir/subdir1/file1.ext" of length 21
55
46
56
-
**Input:** input = "a"
47
+
"dir/subdir2/subsubdir2/file2.ext" of length 32.
57
48
58
-
**Output:** 0
49
+
We return 32 since it is the longest absolute path to a file.
59
50
60
-
**Explanation:** We do not have any files, just a single directory named "a".
61
-
62
-
**Example 4:**
51
+
**Example 3:**
63
52
64
-
**Input:** input = "file1.txt
65
-
file2.txt
66
-
longfile.txt"
53
+
**Input:** input = "a"
67
54
68
-
**Output:**12
55
+
**Output:**0
69
56
70
-
**Explanation:**There are 3 files at the root directory. Since the absolute path for anything at the root directory is just the name itself, the answer is "longfile.txt" with length 12.
57
+
**Explanation:**We do not have any files, just a single directory named "a".
0 commit comments