Practice Longest Absolute File Path
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The string input encodes a valid file system: entries are separated by newline characters, and the number of leading tab characters gives an entry’s nesting depth. Names contain letters, digits, or spaces; files have a name.extension form, while directory names contain no dot. An absolute path joins its directory names and final file name with slashes. Return the greatest character length of such a file path, counting the slashes but not the encoding’s tabs or newlines. Return zero if there are no files. Every name is nonempty.
Source: Longest Absolute File Path on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
input = "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext"
20
# Example 2
input = "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext"
32
# Example 3
input = "a"
0
Constraints
Related LeetCode Problems
Practice more problems similar to Longest Absolute File Path.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.