code: static public final int[] RLEStringToIntArray(String s) {
          int length = getInt(s, 0);
          int[] array = new int[length];
          int ai = 0, i = 1;
  
          int maxI = s.length() / 2;
          while (ai < length && i < maxI) {
              int c = getInt(s, i++);
  
              if (c == ESCAPE) {
                  c = getInt(s, i++);
                  if (c == ESCAPE) {
                      array[ai++] = c;
                  } else {
                      int runLength = c;
                      int runValue = getInt(s, i++);
                      for (int j=0; j<runLength; ++j) {
                          array[ai++] = runValue;
                      }
                  }
              }
              else {
                  array[ai++] = c;
              }
          }
  
          if (ai != length || i != maxI) {
              throw new IllegalStateException("Bad run-length encoded int array");
          }
  
          return array;
      }
docs: Construct an array of ints from a run-length encoded string.