MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / compressq

Method compressq

Java/String/Compress.java:3–17  ·  view source on GitHub ↗
(String str)

Source from the content-addressed store, hash-verified

1public class Compress {
2
3 public static String compressq(String str){
4 String newstr = "";
5 for(int i=0 ; i<str.length() ; i++){
6 Integer count =1;
7 while( i < str.length()-1 && str.charAt(1) == str.charAt(i+1) ){
8 count++;
9 i++;
10 }
11 newstr += str.charAt(i);
12 if(count > 1){
13 newstr += count.toString();
14 }
15 }
16 return newstr;
17 }
18
19
20

Callers 1

mainMethod · 0.95

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected