You are viewing a single comment's thread. Return to all comments →
public static String funnyString(String s) { // Write your code here int count=0; int j=s.length()-1; for(int i=1;i<s.length();i++) { int diff1=Math.abs(s.charAt(i-1)-s.charAt(i)); int diff2=Math.abs(s.charAt(j)-s.charAt(j-1)); if(diff1==diff2) count++; j--; } if(count==(s.length()-1)) return "Funny"; else return "Not 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 →