Skip to content

Commit b4cd28f

Browse files
authored
Update next-greater-numerically-balanced-number.cpp
1 parent b3a25f6 commit b4cd28f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

C++/next-greater-numerically-balanced-number.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ class Solution2 {
2828
public:
2929
int nextBeautifulNumber(int n) {
3030
// obtained by manually enumerating min number of permutations in each length
31-
static const vector<string> balanced = {
32-
"1",
33-
"22",
34-
"122", "333",
35-
"1333", "4444",
36-
"14444", "22333", "55555",
37-
"122333", "155555", "224444", "666666"
31+
static const vector<int> balanced = {
32+
1,
33+
22,
34+
122, 333,
35+
1333, 4444,
36+
14444, 22333, 55555,
37+
122333, 155555, 224444, 666666
3838
};
3939
const auto& s = to_string(n);
4040
int result = 1224444;
41-
for (auto x : balanced) {
41+
for (const auto& i : balanced) {
42+
auto x = to_string(i);
4243
if (size(x) < size(s)) {
4344
continue;
4445
}

0 commit comments

Comments
 (0)