Skip to content

Commit 9afdb50

Browse files
refactor 388
1 parent 103ee64 commit 9afdb50

File tree

1 file changed

+1
-38
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+1
-38
lines changed

src/main/java/com/fishercoder/solutions/_388.java

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,6 @@
22

33
import java.util.Stack;
44

5-
/**
6-
* 388. Longest Absolute File Path
7-
*
8-
* Suppose we abstract our file system by a string in the following manner:
9-
*
10-
* The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents:
11-
*
12-
* dir
13-
* subdir1
14-
* subdir2
15-
* file.ext
16-
* The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext.
17-
*
18-
* The string "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext" represents:
19-
*
20-
* dir
21-
* subdir1
22-
* file1.ext
23-
* subsubdir1
24-
* subdir2
25-
* subsubdir2
26-
* file2.ext
27-
* The directory dir contains two sub-directories subdir1 and subdir2. subdir1 contains a file file1.ext and an empty second-level sub-directory subsubdir1.
28-
* subdir2 contains a second-level sub-directory subsubdir2 containing a file file2.ext.
29-
*
30-
* We are interested in finding the longest (number of characters) absolute path to a file within our file system.
31-
* For example, in the second example above, the longest absolute path is "dir/subdir2/subsubdir2/file2.ext", and its length is 32 (not including the double quotes).
32-
*
33-
* Given a string representing the file system in the above format, return the length of the longest absolute path to file in the abstracted file system. If there is no file in the system, return 0.
34-
*
35-
* Note:
36-
*
37-
* The name of a file contains at least a . and an extension.
38-
* The name of a directory or sub-directory will not contain a ..
39-
* Time complexity required: O(n) where n is the size of the input string.
40-
*
41-
* Notice that a/aa/aaa/file1.txt is not the longest file path, if there is another path aaaaaaaaaaaaaaaaaaaaa/sth.png.*/
425
public class _388 {
436
public static class Solution1 {
447
public int lengthLongestPath(String input) {
@@ -55,7 +18,7 @@ public int lengthLongestPath(String input) {
5518
currLevel = nextLevel;
5619
int currStrLen = 0;
5720
while (i < input.length() && (Character.isLetterOrDigit(input.charAt(i))
58-
|| period.equals(input.charAt(i)) || space.equals(input.charAt(i)))) {
21+
|| period.equals(input.charAt(i)) || space.equals(input.charAt(i)))) {
5922
if (period.equals(input.charAt(i))) {
6023
isFile = true;
6124
}

0 commit comments

Comments
 (0)