Monday, December 14, 2015

Related Strings : Interview Coding

Problem Statement
Two strings S1 and S2 are "Related" if one of the condition holds true: 
1) They are equal 
2) If we divide string S1 into two halves of the same size S11 and S12, and string S2 into two halves of the same size S21 and S22, then one of the following is correct:
A: S11 is Related to S21 and S12 is Related to S22.
B: S11 is Related to S22 and S12 is Related to S21.
You are given a two strings S1 and S2 print "YES" if they are related otherwise Print "NO".
Input Format
Two space separated strings.
Output Format
Print "YES" if given two string are related otherwise print "NO".
Sample Input
aaba abaa
Sample Output
YES
Solution

No comments:

Post a Comment