@@ -0,0 +1,2097 @@
+/**%0A * // This is the interface that allows for creating nested lists.%0A * // You should not implement it, or speculate about its implementation%0A * public interface NestedInteger %7B%0A *     // Constructor initializes an empty nested list.%0A *     public NestedInteger();%0A *%0A *     // Constructor initializes a single integer.%0A *     public NestedInteger(int value);%0A *%0A *     // @return true if this NestedInteger holds a single integer, rather than a nested list.%0A *     public boolean isInteger();%0A *%0A *     // @return the single integer that this NestedInteger holds, if it holds a single integer%0A *     // Return null if this NestedInteger holds a nested list%0A *     public Integer getInteger();%0A *%0A *     // Set this NestedInteger to hold a single integer.%0A *     public void setInteger(int value);%0A *%0A *     // Set this NestedInteger to hold a nested list and adds a nested integer to it.%0A *     public void add(NestedInteger ni);%0A *%0A *     // @return the nested list that this NestedInteger holds, if it holds a nested list%0A *     // Return null if this NestedInteger holds a single integer%0A *     public List%3CNestedInteger%3E getList();%0A * %7D%0A */%0A// Solution runs in O(n) time and uses O(n) space (virtual callstack + substrings)%0A// TODO: prove time complexity%0Apublic class Solution %7B%0A  public NestedInteger deserialize(String s) %7B%0A    if (s.charAt(0) == '%5B') %7B%0A      NestedInteger ni = new NestedInteger();%0A      int start = 1, end = s.length() - 2;%0A      while (start %3C= end) %7B%0A        int i = start;%0A        if (s.charAt(i) == '%5B') %7B%0A          Stack%3CCharacter%3E stack = new Stack%3CCharacter%3E();%0A          do %7B%0A            if (s.charAt(i) == '%5B') %7B%0A              stack.push('%5B');%0A            %7D else if (s.charAt(i) == '%5D') %7B%0A              stack.pop();%0A            %7D%0A            i++;%0A          %7D while (!stack.isEmpty());%0A        %7D else %7B%0A          i = s.indexOf(',', i);%0A          i = i %3C 0 ? (end + 1) : i;%0A        %7D%0A        ni.add(deserialize(s.substring(start, i)));%0A        start = i + 1;%0A      %7D%0A      return ni;%0A    %7D else %7B%0A      return new NestedInteger(Integer.parseInt(s));%0A    %7D%0A  %7D%0A%7D%0A

add solution