#K75627. Scrambled String Checker
Scrambled String Checker
Scrambled String Checker
Given two strings \(s_1\) and \(s_2\), determine whether \(s_2\) is a scrambled version of \(s_1\). A string \(s_2\) is said to be a scrambled version of \(s_1\) if it can be produced by recursively partitioning \(s_1\) into two non-empty substrings and swapping them (zero or more times). For example, if \(s_1 = \texttt{great}\), one possible way to scramble it is: partition into \(\texttt{gr}\) and \(\texttt{eat}\); then swap some parts recursively such that it becomes \(\texttt{rgeat}\). The task is to output YES if \(s_2\) is a scrambled version of \(s_1\), and NO otherwise.
Note: The scrambling process is defined recursively. Ensure that the given strings have the same set of characters, and if they do, check all possible partitions to confirm the scrambled equivalence.
inputFormat
The input consists of two strings provided via standard input. The first line contains string \(s_1\) and the second line contains string \(s_2\). Both strings contain only lowercase English letters and have lengths at most 1000.
outputFormat
Output a single line via standard output: YES if \(s_2\) is a scrambled version of \(s_1\), and NO otherwise.
## samplegreat
rgeat
YES