Skip to content

Commit 71c542c

Browse files
authored
Merge pull request kothariji#540 from krishremya/master
added 946C
2 parents 4061208 + 7d722d2 commit 71c542c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

String/(CODEFORCES)946C.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//solution for 946C - https://codeforces.com/contest/946/problem/C
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
int main() {
5+
string str;
6+
cin >> str;
7+
char ch = 'a';
8+
bool flag = false;
9+
for (int i=0 ; i < str.size() ; i++){
10+
if (str[i] <= ch){
11+
str[i] = ch;
12+
if (ch == 'z'){
13+
flag= true;
14+
break;
15+
}
16+
ch= ch + 1;
17+
}
18+
}
19+
if (!flag){
20+
cout << -1 << endl;
21+
}
22+
else{
23+
cout << str << endl;
24+
}
25+
return 0;
26+
}

0 commit comments

Comments
 (0)