Skip to content

Commit 1119b04

Browse files
authored
Update minimum-number-of-operations-to-make-string-sorted.cpp
1 parent 0c2bba4 commit 1119b04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

C++/minimum-number-of-operations-to-make-string-sorted.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Time: O(26 * n) = O(n)
2-
// Space: O(26) = O(1)
2+
// Space: O(max_n) = O(max_n)
33

44
class Solution {
55
public:
66
int makeStringSorted(string s) { // count of prev_permutation
77
static const int MOD = 1e9 + 7;
88

99
array<int, 26> count = {0};
10-
int result = 0, total = 0, comb_total = 1;
10+
int result = 0, comb_total = 1;
1111
for (int i = size(s) - 1; i >= 0; --i) {
1212
int num = s[i] - 'a';
1313
comb_total = ((comb_total * int64_t(size(s) - i) % MOD) * inverse(++count[num], MOD)) % MOD;

0 commit comments

Comments
 (0)