Skip to content

Commit ac3d92d

Browse files
authored
Update readme.md
1 parent e2a6821 commit ac3d92d

File tree

1 file changed

+19
-31
lines changed
  • src/main/kotlin/g0301_0400/s0388_longest_absolute_file_path

1 file changed

+19
-31
lines changed

src/main/kotlin/g0301_0400/s0388_longest_absolute_file_path/readme.md

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,55 @@ Here, we have `dir` as the only directory in the root. `dir` contains two subdir
1010

1111
In text form, it looks like this (with ⟶ representing the tab character):
1212

13-
dir
14-
⟶ subdir1
15-
⟶ ⟶ file1.ext
16-
⟶ ⟶ subsubdir1
17-
⟶ subdir2
18-
⟶ ⟶ subsubdir2
19-
⟶ ⟶ ⟶ file2.ext
20-
21-
If we were to write this representation in code, it will look like this: `"dir
22-
\tsubdir1
23-
\t\tfile1.ext
24-
\t\tsubsubdir1
25-
\tsubdir2
26-
\t\tsubsubdir2
27-
\t\t\tfile2.ext"`. Note that the `'
13+
dir ⟶ subdir1 ⟶ ⟶ file1.ext ⟶ ⟶ subsubdir1 ⟶ subdir2 ⟶ ⟶ subsubdir2 ⟶ ⟶ ⟶ file2.ext
14+
15+
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 `'
2817
'` and `'\t'` are the new-line and tab characters.
2918

3019
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.
3120

3221
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`.
3322

23+
**Note** that the testcases are generated such that the file system is valid and no file or directory name has length 0.
24+
3425
**Example 1:**
3526

3627
![](https://assets.leetcode.com/uploads/2020/08/28/dir1.jpg)
3728

38-
**Input:** input = "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext"
29+
**Input:** input = "dir\n\\tsubdir1\n\\tsubdir2\n\\t\\tfile.ext"
3930

4031
**Output:** 20
4132

42-
**Explanation:** We have only one file, and the absolute path is "dir/subdir2/file.ext" of length 20.
33+
**Explanation:** We have only one file, and the absolute path is "dir/subdir2/file.ext" of length 20.
4334

4435
**Example 2:**
4536

4637
![](https://assets.leetcode.com/uploads/2020/08/28/dir2.jpg)
4738

48-
**Input:** input = input = "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext"
39+
**Input:** input = "dir\n\\tsubdir1\n\\t\\tfile1.ext\n\\t\\tsubsubdir1\n\\tsubdir2\n\\t\\tsubsubdir2\n\\t\\t\\tfile2.ext"
4940

5041
**Output:** 32
5142

52-
**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:
5344

54-
**Example 3:**
45+
"dir/subdir1/file1.ext" of length 21
5546

56-
**Input:** input = "a"
47+
"dir/subdir2/subsubdir2/file2.ext" of length 32.
5748

58-
**Output:** 0
49+
We return 32 since it is the longest absolute path to a file.
5950

60-
**Explanation:** We do not have any files, just a single directory named "a".
61-
62-
**Example 4:**
51+
**Example 3:**
6352

64-
**Input:** input = "file1.txt
65-
file2.txt
66-
longfile.txt"
53+
**Input:** input = "a"
6754

68-
**Output:** 12
55+
**Output:** 0
6956

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".
7158

7259
**Constraints:**
7360

7461
* <code>1 <= input.length <= 10<sup>4</sup></code>
7562
* `input` may contain lowercase or uppercase English letters, a new line character `'
76-
'`, a tab character `'\t'`, a dot `'.'`, a space `' '`, and digits.
63+
'`, a tab character `'\t'`, a dot `'.'`, a space `' '`, and digits.
64+
* All file and directory names have **positive** length.

0 commit comments

Comments
 (0)