//sample solution
function isTandemRepeat(inputString) {
var temp=inputString.length;
if(temp%2!=0){
return false;
} else {
var midIndex = temp/2;
var firstHalf = inputString.slice(0,midIndex);
var secondHalf = inputString.slice(midIndex,temp);
if(firstHalf.localeCompare(secondHalf)==0){
return true;
} else {
return false;
}
}
}
No comments:
Post a Comment