You are viewing a single comment's thread. Return to all comments →
JavaScript
function happyLadybugs(b) { // Write your code here
let underscore = 0; let arr = new Array(27).fill(0); let a = 0; let flag = 0; for(let i = 'A'.charCodeAt(0); i <= 'Z'.charCodeAt(0); i++){ for(let j = 0; j < b.length; j++){ if(b[j] == '_'){ underscore ++; } if(String.fromCharCode(i) == b[j]){ if(arr[a] != 0 && b[j] != b[j - 1]){ flag = 1; } arr[a] ++; } } a ++; } for(let i = 0; i < arr.length; i++){ if(arr[i] == 1){ return 'NO'; } } if(underscore > 0){ return 'YES'; } if(flag != 1){ return 'YES'; } return 'NO';
}
Seems like cookies are disabled on this browser, please enable them to open this website
Happy Ladybugs
You are viewing a single comment's thread. Return to all comments →
JavaScript
function happyLadybugs(b) { // Write your code here
}