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.
hi @etayluz i think that you can optimize this code more because you use 2 cycles for in my solution i use 1 for and while
functionprocessData(input){//Enter your code hereinput=input.split('\n')varn=input[0];for(varz=1;z<=n;z++){vars=input[z].split('');varr=input[z].split('').reverse();varj=1;vari=1;while(j<=s.length-1){if(Math.abs(s[j].charCodeAt()-s[j-1].charCodeAt())==Math.abs(r[j].charCodeAt()-r[j-1].charCodeAt())){i++;}j++;}if(i==s.length){console.log('Funny')}else{console.log('Not Funny')}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Funny String
You are viewing a single comment's thread. Return to all comments →
hi @etayluz i think that you can optimize this code more because you use 2 cycles for in my solution i use 1 for and while