We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a13a5c8 commit 035fc55Copy full SHA for 035fc55
1 file changed
C++/largest-number.cpp
@@ -15,12 +15,12 @@ class Solution {
15
16
// combine the numbers
17
string max_num;
18
- for (auto& i : num) {
+ for (const auto& i : num) {
19
max_num.append(to_string(i));
20
}
21
22
// special case: start with zero (e.g. [0, 0])
23
- if (max_num[0] == '0') {
+ if (!max_num.empty() && max_num[0] == '0') {
24
return "0";
25
26
0 commit comments