process_str(StringBuilder copy, List<Integer> idxList) {
for(int i = 0; i < idxList.size(); ++i) {
int pos = idxList.get(i);
copy.setCharAt(pos, '$');
}
StringBuilder output = new StringBuilder();
for(int i = 0; i < copy.length(); ++i) {
char ch = copy.charAt(i);
if(ch != '$')
output.append(ch);
}
return output.toString();
}
Constraint - $ does not appear in the input string. Is there a simpler way to do this?