-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomaprestring.cpp
More file actions
41 lines (30 loc) · 766 Bytes
/
Copy pathcomaprestring.cpp
File metadata and controls
41 lines (30 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
string removeDigit(string number, char digit) {
priority_queue<string> p;
for( int i = 0; i < number.size() ; i++){
string copyNum = number;
if(number[i] == digit){
copyNum.erase(i, 1);
cout << copyNum << endl;
p.push(copyNum);
}
}
return p.top();
}
string removeDigit2(string number, char digit) {
string maxStr = "0";
for( int i = 0; i < number.size() ; i++){
string copyNum = number;
if(number[i] == digit){
copyNum.erase(i, 1);
maxStr = max(maxStr, copyNum);
}
}
return maxStr;
}
int main(){
string a = "512131";
cout << removeDigit(a, '1');
return 0;
}