Playful Strings
Practice
3 (61 votes)
Easy
Implementation
String manipulation
Problem
33% Success 10026 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given a string S of length N, you have to tell whether it is playful or not. A playful string is one where the distance between any two adjacent character is exactly 1. Consider that the alphabets are arranged in cyclic manner from 'a' to 'z'. Hence, distance between any character 'i' and 'j' will be defined as minimum number of steps it takes 'i' to reach 'j'. Here, character 'i' can start moving clockwise or anti-clockwise in order to reach at position where character 'j' is placed. Your task is simple, where you just need to print "YES" or "NO"(without quotes) depending on whether the given string is playful or not.

Input
First line of the input contains T denoting the number of test cases.
T lines follow, each having a string S.

Output
Print the answer for each testcase in a separate line.

Constraints

  • \(1 ≤ T ≤ 50\)
  • \(1 ≤ |S| ≤ 50\)
  • S contains only lowercase alphabetic characters

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
42 votes
Tags:
Data StructuresEasySortingString Manipulationapproved
Points:20
16 votes
Tags:
AlgorithmsString SearchingString Algorithms
Points:20
7 votes
Tags:
AlgorithmsEasyString Manipulation