Strobogrammatic number funtion gives correct output on jsfiddle but wrong on leetcode for JS
/**
 * @param {string} num
 * @return {boolean}
 */
var isStrobogrammatic = function(num) {
    let mirrorDigit=new Set([0,1,6,8,9]);
    let orNum=num.toString();
    let len=orNum.length;
    let i=0;
    let res=true;
    if(len<=1 && (!(mirrorDigit.has(num)) || (num==6 || num ==9))){
        res=false;
        }
    while(num>0 && len>1){
        let d=Math.floor(num%10);
        if(mirrorDigit.has(d)){
            if(d==6 || d==9){
            let du=15-d;
                if((orNum.charAt(len-1-i)!='' && orNum.charAt(len-1-i)!=d)){
                res=false;break;
                }
                
        }
        }else{
            res=false;break;
        }
        num=num/10;
        i++;
    }
    return res;
};
Comments (0)