题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
let str = readline().split('') let m = new Map() str.forEach(e=>{ if(m.has(e)){ m.set(e,m.get(e)+1) }else{ m.set(e,1) } }) let smallest = Math.min(...m.values()) let del = [] m.forEach((value,key)=>{ if(value==smallest){ del.push(key) } }) str = str.join('') del.forEach(n=>{ let re = new RegExp(n,'g') str = str.replace(re,'') }) print(str)