All Tracks Algorithms String Algorithms Basics of String Manipulation Problem

Alice and Strings
/

Algorithms, String Manipulation

Problem
Editorial
Analytics

Two strings \(A\) and \(B\) comprising of lower case English letters are compatible if they are equal or can be made equal by following this step any number of times:

  • Select a prefix from the string \(A\) (possibly empty), and increase the alphabetical value of all the characters in the prefix by the same valid amount. For example if the string is \(xyz\) and we select the prefix \(xy\) then we can convert it to \(yz\) by increasing the alphabetical value by 1. But if we select the prefix \(xyz\) then we cannot increase the alphabetical value.

Your task is to determine if given strings \(A\) and \(B\) are compatible.

Input format

First line: String \(A\) 

Next line: String \(B\)

Output format

For each test case, print \(YES\) if string \(A\) can be converted to string \(B\) , otherwise print \(NO\).

Constraints

\(1 \le len(A) \le 1000000\\ 1 \le len(B) \le 1000000\)

SAMPLE INPUT
abaca
cdbda
SAMPLE OUTPUT
YES
Explanation

The string \(abaca\) can be converted to \(bcbda\) in one move and to \(cdbda\) in the next move.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?