You are viewing a single comment's thread. Return to all comments →
We don't need to reverse the string. here is one simple solution for this problem in java and it was accepted.
static String funnyString(String s) {
int n = s.length(); for(int i=0;i<n-1;i++){ int st = Math.abs(s.charAt(i) - s.charAt(i+1)); int rev = Math.abs(s.charAt(n-i-1) - s.charAt(n-i-2)); if(st != rev){ return "Not Funny"; } } return "Funny"; }
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 →
We don't need to reverse the string. here is one simple solution for this problem in java and it was accepted.
static String funnyString(String s) {