Skip to content

Commit f484231

Browse files
authored
Merge pull request gzc426#142 from wswdwf/patch-4
Create Sagittarius.md
2 parents d5a3a16 + 39404e4 commit f484231

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2018.11.29-leetcode443/Sagittarius.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```
2+
class Solution {
3+
public:
4+
int compress(vector<char>& chars) {
5+
int count=0;
6+
int index=0;
7+
for(int i=0;i<chars.size();i++)
8+
{
9+
count++;
10+
if(i==chars.size()-1||chars[i]!=chars[i+1])
11+
{
12+
chars[index++]=chars[i];
13+
if(count!=1)
14+
{
15+
for(auto ch:to_string(count))
16+
chars[index++]=ch;
17+
}
18+
count=0;
19+
}
20+
21+
}
22+
23+
return index;
24+
}
25+
};
26+
```

0 commit comments

Comments
 (0)