why it so slowly to use RegExp in JavaScrtip


  • 0
    S

    passed all cases runtime are 206ms

    var detectCapitalUse = function(word) {
        re1 = /\b[A-Z]{1}([a-z]+||[A-Z]+)\b/;
        re2 = /\b[a-z]+\b/;
        if(re1.test(word)||re2.test(word)){
        	return true;
        }else{
        	return false;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.