Skip to content

Commit

Permalink
Create RemoveDigitToMaximizeResult.java
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithasudhakar authored Dec 25, 2024
1 parent 053968d commit 91a9857
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Strings/RemoveDigitToMaximizeResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class RemoveDigitToMaximizeResult {
public String removeDigit(String number, char digit) {
String result = "";
for(int i = 0; i<number.length(); i++){
if(number.charAt(i) == digit){
String str = number.substring(0,i) + number.substring(i+1);

if(str.compareTo(result) > 0){
result = str;
}
}
}
return result;
}
}

0 comments on commit 91a9857

Please sign in to comment.