We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ffc763a commit 087ef97Copy full SHA for 087ef97
2018.11.29-leetcode443/。。。.md
@@ -0,0 +1,26 @@
1
+ public int compress(char[] chars) {
2
+ int cur = 1;//压缩后字符串的长度
3
+ int repet = 1;
4
+ for (int i = 1; i < chars.length; i++){
5
+ if (chars[i-1] == chars[i]) {//出现连续重复的字符串
6
+ repet++;
7
+ }else {
8
+ if (repet!=1){
9
+ char[] num = String.valueOf(repet).toCharArray();
10
+ for (int j = 0; j < num.length; j++){
11
+ chars[cur++] = num[j];
12
+ }
13
+ repet=1;
14
15
+ chars[cur++] = chars[i];
16
17
18
19
20
21
22
23
24
+ Log.d(new String(chars));
25
+ return cur;
26
0 commit comments