package leetcode;

/**
 * https://leetcode.com/problems/longest-absolute-file-path/
 */
public class Problem388 {
    public int lengthLongestPath(String input) {
        // TODO:
        return 0;
    }

    public static void main(String[] args) {
        Problem388 prob = new Problem388();
        System.out.println(prob.lengthLongestPath("dir\\n\\tsubdir1\\n\\t\\tfile1.ext\\n\\t\\tsubsubdir1\\n\\tsubdir2\\n\\t\\tsubsubdir2\\n\\t\\t\\tfile2.ext")); // 32
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -217,34 +217,1004 @@
     
-// TODO:%0A        return 0;
+String%5B%5D split = input.split(%22%5C%5Cn%22);%0A        Map%3CInteger, Integer%3E levelToLengthMap = new HashMap%3C%3E();%0A        // TODO%0A        for (String s : split) %7B%0A            int idx = 0;%0A            int currentLevel = 0;%0A            while (s.charAt(idx++) == '%5Ct') %7B%0A                currentLevel++;%0A            %7D%0A            int parentLevel = currentLevel - 1;%0A            int length = 0;%0A            if (parentLevel %3E= 0) %7B%0A                length = levelToLengthMap.get(parentLevel) + 1;%0A            %7D%0A            length += s.length() - currentLevel;%0A            levelToLengthMap.put(currentLevel, length);%0A        %7D%0A        int max = 0;%0A        for (int length : levelToLengthMap.values()) %7B%0A            max = Math.max(max, length);%0A        %7D%0A        return max;%0A    %7D%0A%0A    private static class LevelLength %7B%0A        private final int level;%0A        private final int length;%0A%0A        public LevelLength(int level, int length) %7B%0A            this.level = level;%0A            this.length = length;%0A        %7D
 %0A   
@@ -1361,19 +1361,17 @@
 th(%22dir%5C
-%5Cn%5C
+n
 %5Ctsubdir
@@ -1372,23 +1372,20 @@
 subdir1%5C
-%5Cn%5C
+n
 %5Ct%5C
-%5C
 tfile1.e
@@ -1387,23 +1387,20 @@
 le1.ext%5C
-%5Cn%5C
+n
 %5Ct%5C
-%5C
 tsubsubd
@@ -1403,20 +1403,18 @@
 subdir1%5C
-%5C
 n%5C
-%5C
 tsubdir2
@@ -1414,23 +1414,20 @@
 subdir2%5C
-%5Cn%5C
+n
 %5Ct%5C
-%5C
 tsubsubd
@@ -1434,17 +1434,13 @@
 ir2%5C
-%5Cn%5C%5Ct%5C%5Ct%5C
+n%5Ct%5Ct
 %5Ctfi

Update problem 388