题解 | #数组中只出现一次的两个数字#

数组中只出现一次的两个数字

http://www.nowcoder.com/practice/389fc1c3d3be4479a154f63f495abff8

 * 
 * @param array int整型一维数组 
 * @return int整型一维数组
 */
function FindNumsAppearOnce( array ) {
    let map = new Map() , res = []
    for(let i of array){
        map.has(i) ? map.set(i , map.get(i) + 1) : map.set(i , 1)
    }
    for(let key of map.keys()){
        if(map.get(key) === 1) res.push(key)
    }
    return res.sort((a , b) => a - b)
        
}
module.exports = {
    FindNumsAppearOnce : FindNumsAppearOnce
};
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务