题目:

题解:
func lengthLongestPath(input string) (ans int) {
n := len(input)
level := make([]int, n+1)
for i := 0; i < n; {
// 检测当前文件的深度
depth := 1
for ; i < n && input[i] == '\t'; i++ {
depth++
}
// 统计当前文件名的长度
length, isFile := 0, false
for ; i < n && input[i] != '\n'; i++ {
if input[i] == '.' {
isFile = true
}
length++
}
i++ // 跳过换行符
if depth > 1 {
length += level[depth-1] + 1
}
if isFile {
ans = max(ans, length)
} else {
level[depth] = length
}
}
return
}
func max(a, b int) int {
if b > a {
return b
}
return a
}




![[免越狱]FLEXTool/FLEX 炫酷功能怎么添加到目标App](https://img-blog.csdnimg.cn/img_convert/d73018ec3f4ce1a854be778f610ed800.png)

![[Labview]图片叠加下的表格视图拖拽功能:挖坑粗糙版](https://i-blog.csdnimg.cn/direct/fec9b24f50bc40a8b452b10b44cf6533.gif)

![[Algorithm][综合训练][过桥][最大差值][兑换零钱]详细讲解](https://i-blog.csdnimg.cn/direct/44202091b89a408c96b7be86da7184c3.png)









