MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / clearDigits

Method clearDigits

ClearDigits.java:2–15  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

1class Solution {
2 public String clearDigits(String s) {
3 StringBuilder sb = new StringBuilder();
4 int n = s.length();
5 for(int i=0;i<n;i++){
6 if(!Character.isDigit(s.charAt(i))){
7 sb.append(s.charAt(i));
8 }else{
9 if(sb.length()!=0){
10 sb.deleteCharAt(sb.length()-1);
11 }
12 }
13 }
14 return sb.toString();
15 }
16}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected