You are viewing a single comment's thread. Return to all comments →
no need to reversing the string. we can do it simply by parsing from right to left.
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution {
static string funnyString(string s){ // Complete this function bool ans=false; for(int i=1,j=s.Length-2;i<s.Length;i++,j--) { if(Math.Abs(s[j]-s[j+1])!=Math.Abs(s[i]-s[i-1])) { ans=true; break; } } return (ans?"Not Funny":"Funny"); } static void Main(String[] args) { int q = Convert.ToInt32(Console.ReadLine()); for(int a0 = 0; a0 < q; a0++){ string s = Console.ReadLine(); string result = funnyString(s); Console.WriteLine(result); } }
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 →
no need to reversing the string. we can do it simply by parsing from right to left.
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution {