We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functiontowerBreakers(arr){// Write your code hereletsumArr=[];for(leti=0;i<arr.length;i++){letsum=0;if(arr[i]===2||arr[i]===3)sum++;else{for(letj=2;j<=arr[i];j++){while(arr[i]%j==0){sum++;arr[i]=arr[i]/j;}}}sumArr.push(sum);}returnsumArr.reduce((a,v)=>(a^=v))?"1":"2";}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tower Breakers, Revisited!
You are viewing a single comment's thread. Return to all comments →
JS: