Skip to content

Commit b3eb3ed

Browse files
authored
Update number-of-atoms.cpp
1 parent 86940bb commit b3eb3ed

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

C++/number-of-atoms.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ class Solution {
77
stack<map<string, int>> stk;
88
stk.emplace();
99
int submatches[] = { 1, 2, 3, 4, 5 };
10-
auto e = regex("([A-Z][a-z]*)(\\d*)|(\\()|(\\))(\\d*)");
10+
const auto e = regex("([A-Z][a-z]*)(\\d*)|(\\()|(\\))(\\d*)");
1111
for (regex_token_iterator<string::iterator> it(formula.begin(), formula.end(), e, submatches), end;
1212
it != end;) {
13-
auto name = (it++)->str();
14-
auto m1 = (it++)->str();
15-
auto left_open = (it++)->str();
16-
auto right_open = (it++)->str();
17-
auto m2 = (it++)->str();
13+
const auto& name = (it++)->str();
14+
const auto& m1 = (it++)->str();
15+
const auto& left_open = (it++)->str();
16+
const auto& right_open = (it++)->str();
17+
const auto& m2 = (it++)->str();
1818
if (!name.empty()) {
1919
stk.top()[name] += stoi(!m1.empty() ? m1 : "1");
2020
}

0 commit comments

Comments
 (0)