MCPcopy Create free account
hub / github.com/careercup/ctci / setChar

Method setChar

java/Chapter 1/Question1_5/Question.java:5–14  ·  view source on GitHub ↗
(char[] array, char c, int index, int count)

Source from the content-addressed store, hash-verified

3public class Question {
4
5 public static int setChar(char[] array, char c, int index, int count) {
6 array[index] = c;
7 index++;
8 char[] cnt = String.valueOf(count).toCharArray();
9 for (char x : cnt) {
10 array[index] = x;
11 index++;
12 }
13 return index;
14 }
15
16 public static int countCompression(String str) {
17 if (str == null || str.isEmpty()) return 0;

Callers 1

compressAlternateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected