You are viewing a single comment's thread. Return to all comments →
public static void checkStringisFunny(String str) { char[] chars = str.toCharArray(); int j = chars.length-1;
for(int i = 1 ;i<chars.length;i++) { if(Math.abs((int)chars[i]-(int)chars[i-1])== Math.abs((int)chars[j]-(int)chars[j-1])) { j--; continue; }else { System.out.println("Not Funny"); return; } } System.out.println("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 →
public static void checkStringisFunny(String str) { char[] chars = str.toCharArray(); int j = chars.length-1;