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.
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int l=0;l<t;l++){
String str=sc.next();
int n=str.length();
//System.out.println(n);
char[] strarray= str.toCharArray();
// for(char c:strarray)
// System.out.print(c);
// System.out.println();
char[] revarray=new char[n];
int j=n-1;
for (int i=0; i < n ; i++,j--)
{
revarray[i]=strarray[j];
}
//for(char c:revarray)
//System.out.print(c);
//System.out.println();
String result="";
for( int i=1;i<n;i++){
// System.out.println("in for loop");
int a=strarray[i];
int b=strarray[i-1];
int c=a-b;
int d=Math.abs(c);
//System.out.println(a+" "+b+" "+c+" "+d);
int e=revarray[i];
int f=revarray[i-1];
int g=e-f;
int h=Math.abs(g);
// System.out.println(e+" "+f+" "+g+" "+h);
if(d!=h)
{ result="Not Funny";
break;}
else{
result="Funny";
}
}
System.out.println(result);
}
}
}
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 →
import java.io.; import java.util.;
public class Solution {
} }