@@ -0,0 +1,1502 @@
+import java.util.Stack;%0A%0Apublic class LeetCode0071 %7B%0A%09public String simplifyPath(String path) %7B%0A%09%09if (path == null %7C%7C path.length() == 0) %7B%0A%09%09%09return path;%0A%09%09%7D%0A%0A%09%09Stack%3CCharacter%3E stack = new Stack%3CCharacter%3E();%0A%09%09int pointCount = 0;%0A%0A%09%09for (int i = 0; i %3C path.length(); i++) %7B%0A%09%09%09char c = path.charAt(i);%0A%09%09%09%0A%09%09%09if (c == '.') %7B%0A%09%09%09%09pointCount++;%0A%09%09%09%7D%0A%09%09%09else if (c == '/') %7B%0A%0A%09%09%09%09if (pointCount == 2 && !stack.isEmpty()) %7B%0A%09%09%09%09%09stack.pop();%0A%09%09%09%09%09while (!stack.isEmpty() && stack.peek() != '/') %7B%0A%09%09%09%09%09%09stack.pop();%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%09if(pointCount %3E 2) %7B%0A%09%09%09%09%09for (; pointCount %3E 0; pointCount--)%0A%09%09%09%09%09%09stack.push('.');%0A%09%09%09%09%7D%0A%09%09%09%09pointCount = 0;%0A%09%09%09%09if (!stack.isEmpty() && stack.peek() == '/') %7B%0A%09%09%09%09%09continue;%0A%09%09%09%09%7D%0A%09%09%09%09stack.push('/');%0A%09%09%09%7D else %7B%09%09%09%09%0A%09%09%09%09for (; pointCount %3E 0; pointCount--)%0A%09%09%09%09%09stack.push('.');%0A%09%09%09%09stack.push(c);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09if(pointCount%3E 2) %7B%0A%09%09%09for (; pointCount %3E 0; pointCount--)%0A%09%09%09%09stack.push('.');%0A%09%09%7D%0A%09%09%0A%09%09if (pointCount == 2 && !stack.isEmpty()) %7B%0A%09%09%09if(stack.size() %3E 1) %7B%0A%09%09%09%09stack.pop();%0A%09%09%09%7D%0A%09%09%09while (!stack.isEmpty() && stack.peek() != '/') %7B%0A%09%09%09%09stack.pop();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09if (stack.size() %3E 1 && stack.peek() == '/')%0A%09%09%7B%0A%09%09%09stack.pop();%0A%09%09%7D%0A%09%09%0A%09%09StringBuilder result = new StringBuilder(stack.size());%0A%0A%09%09for (int i = 0; i %3C stack.size(); i++) %7B%0A%09%09%09result.append(stack.get(i));%0A%09%09%7D%0A%0A%09%09return result.toString();%0A%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09LeetCode0071 leetCode = new LeetCode0071();%0A%09%09System.out.println(leetCode.simplifyPath(%22/..%22));%0A%09%7D%0A%7D%0A

Add LeetCode0071.java