获得徽章 0
- 🧄每周一道算法题
function missingLetters(arr){
if(arr.length <=1 ){
return []
}
let res = []
for(let i=0; i<arr.length-1; i++){
let next = arr[i+1].charCodeAt()
let now = arr[i].charCodeAt()
while(next - now > 1){
res.push(String.fromCharCode(++now))
}
}
return res
}
let result1 = missingLetters(['a', 'b', 'c', 'd', 'f'])
let result2 = missingLetters(['a', 'b', 'd', 'e','h','i','j','k','z'])
console.log(result1)
console.log(result2)展开
13
![[流泪]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_6.dde0d83.png)
![[灵光一现]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_25.51e6984.png)
![[不失礼貌的微笑]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_16.9d17f6d.png)
![[思考]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_15.f58c082.png)