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 6eed7ba commit 3abfd93Copy full SHA for 3abfd93
encode-and-decode-strings/flynn.cpp
@@ -27,15 +27,16 @@ class Codec {
27
// Decodes a single string to a list of strings.
28
vector<string> decode(string s) {
29
vector<string> res;
30
- int str_size = 0;
31
- string tmp = "";
32
33
auto it = s.begin();
34
while (it != s.end()) {
35
- do {
+ int str_size = 0;
+ string tmp = "";
+
36
+ while (*it != '.') {
37
str_size = str_size * 10 + (*it - '0');
38
it++;
- } while (*it != '.');
39
+ }
40
41
42
@@ -45,8 +46,6 @@ class Codec {
45
46
}
47
48
res.push_back(tmp);
- str_size = 0;
49
- tmp = "";
50
51
52
return res;
0 commit comments