#K43987. Special String Checker
Special String Checker
Special String Checker
A string is defined to be special if and only if for every pair of consecutive characters in the string, the absolute difference between their ASCII values is exactly 1. In other words, for a string S of length n, it is special if for every index i such that 2 ≤ i ≤ n, we have
\(|S_i - S_{i-1}| = 1\)
This means that a single-character string is always considered special. For example, the string "abc" is special because |'b' - 'a'| = 1 and |'c' - 'b'| = 1, while the string "abd" is not special since |'d' - 'b'| ≠ 1.
Your task is to determine whether a given string is special.
inputFormat
The input consists of a single line containing a string. The string will only contain printable ASCII characters.
outputFormat
Output a single line containing YES
if the string is special; otherwise, output NO
.
abc
YES