package leetcode;

/**
 * https://leetcode.com/problems/string-compression/
 */
public class Problem443 {
    public int compress(char[] chars) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem443 prob = new Problem443();
        System.out.println(prob.compress(new char[]{'a', 'a', 'b', 'b', 'c', 'c', 'c'})); // 6
        System.out.println(prob.compress(new char[]{'a'})); // 1
        System.out.println(prob.compress(new char[]{'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b'})); // 4
    }
}

@@ -151,126 +151,354 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem443 prob = new Problem443
+int j = 0;%0A        char ch = ' ';%0A        int count = 1;%0A        for (int i = 0; i %3C chars.length; i++) %7B%0A            if (i != 0) %7B%0A                if (chars%5Bi%5D != ch) %7B%0A                    chars%5Bj%5D = ch;%0A                    j++;%0A                    if (count %3E 1) %7B%0A                        char%5B%5D countArray = Integer.toString(count).toCharArray
 ();%0A
@@ -509,284 +509,603 @@
     
+ 
-System.out.println(prob.compress(new char%5B%5D%7B'a', 'a', 'b', 'b', 'c', 'c', 'c'%7D)); // 6%0A        System.out.println(prob.compress(new char%5B%5D%7B'a'%7D)); // 1%0A        System.out.println(prob.compress(new char%5B%5D%7B'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b'%7D)); // 4
+               for (int k = 0; k %3C countArray.length; k++) %7B%0A                            chars%5Bj++%5D = countArray%5Bk%5D;%0A                        %7D%0A                    %7D%0A                    count = 1;%0A                %7D else %7B%0A                    count++;%0A                %7D%0A            %7D%0A            ch = chars%5Bi%5D;%0A        %7D%0A        chars%5Bj%5D = ch;%0A        j++;%0A        if (count %3E 1) %7B%0A            char%5B%5D countArray = Integer.toString(count).toCharArray();%0A            for (int k = 0; k %3C countArray.length; k++) %7B%0A                chars%5Bj++%5D = countArray%5Bk%5D;%0A            %7D%0A        %7D%0A        return j;
 %0A   

Solve problem 443