public static ArrayList<Integer> decode(String s) {
        ArrayList<Integer> ret = new ArrayList<Integer>();
        int idx = 0;
        while (idx < s.length()) {
            // Count the number of consecutive 0s.
            int zero_idx = idx;
            while (zero_idx < s.length() && s.charAt(zero_idx) == '0') {
                ++zero_idx;
            }

            int len = zero_idx - idx;
            ret.add(trans_binary_to_int(s.substring(zero_idx, zero_idx + len)));
            idx = zero_idx + len;
        }
        return ret;
    }