forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
28 lines (25 loc) · 793 Bytes
/
Solution.java
File metadata and controls
28 lines (25 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static String funnyString(String s){
String r = (new StringBuffer(s)).reverse().toString();
for (int i = 1; i < s.length(); i++) {
if (Math.abs(((int)s.charAt(i)) - ((int)s.charAt(i-1))) != Math.abs(((int)r.charAt(i)) - ((int)r.charAt(i-1)))) {
return "Not Funny";
}
}
return "Funny";
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int q = in.nextInt();
for(int a0 = 0; a0 < q; a0++){
String s = in.next();
String result = funnyString(s);
System.out.println(result);
}
}
}