You are viewing a single comment's thread. Return to all comments →
My solution in java 7 pass all tests public class Solution {
public static boolean isFunny(String s){ String r= new StringBuilder(s).reverse().toString(); boolean isFunny=false; int j=1; while(Math.abs(s.charAt(j)-s.charAt(j-1))== Math.abs(r.charAt(j)-r.charAt(j-1)) && j<s.length()){ j++; if(j==s.length()){ isFunny=true; break; } } return isFunny; } public static void main(String[] args) { Scanner in= new Scanner(System.in); int t = in.nextInt(); for(int i=0;i<t;i++){ String s = in.next(); String r= new StringBuilder(s).reverse().toString(); if(isFunny(s)==true) System.out.println("Funny"); else System.out.println("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 →
My solution in java 7 pass all tests public class Solution {
}