@@ -0,0 +1,1626 @@
+package leetcode;%0A%0Aimport java.util.ArrayDeque;%0Aimport java.util.Deque;%0A%0Apublic class Task394 %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(new Task394().decodeString(%223%5Ba%5D2%5Bbc%5D%22));%0A        System.out.println(new Task394().decodeString(%223%5Ba2%5Bc%5D%5D%22));%0A        System.out.println(new Task394().decodeString(%2210%5Babc%5D%22));%0A    %7D%0A%0A    public String decodeString(String s) %7B%0A        Deque%3CEncodedString%3E encodedStrings = new ArrayDeque%3C%3E();%0A        encodedStrings.addLast(new EncodedString(1));%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            char ch = s.charAt(i);%0A            if (Character.isAlphabetic(ch)) %7B%0A                encodedStrings.getLast().content.append(ch);%0A            %7D else if (Character.isDigit(ch)) %7B%0A                int j = i + 1;%0A                while (Character.isDigit(s.charAt(j))) %7B%0A                    j++;%0A                %7D%0A                encodedStrings.addLast(new EncodedString(Integer.parseInt(s.substring(i, j))));%0A                i = j;%0A            %7D else if (ch == '%5D') %7B%0A                EncodedString lastEncodedString = encodedStrings.removeLast();%0A                for (int j = 0; j %3C lastEncodedString.amount; j++) %7B%0A                    encodedStrings.getLast().content.append(lastEncodedString.content);%0A                %7D%0A            %7D%0A        %7D%0A        return encodedStrings.removeLast().content.toString();%0A    %7D%0A%0A    private static class EncodedString %7B%0A        private final StringBuilder content = new StringBuilder();%0A        private final int amount;%0A%0A        private EncodedString(int amount) %7B%0A            this.amount = amount;%0A        %7D%0A    %7D%0A%7D%0A

Add Task394