Reverse the Substring

4

1 votes
Problem

You are given two strings A and B of length N. Your task is to transform string B into string A by applying the following operation on string B. 
-reverse any substring any number of times .
 print "YES" if it can be converted else print "NO".

______________________________________________________________

INPUT

  • first line contains integer N denoting size of string
  • second line of input contains String A
  • third line of input contains String B

______________________________________________________________

OUTPUT

Print "YES" if array can be converted else print "NO".

______________________________________________________________

CONSTRAINTS

1<=N<=106

A & B contain only lower case alphabets. 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In "rapapizza" if we choose substring from 1 to 5 (inclusive) "rapap" and reverse it we obtain "paparizza" then we choose substring from 6 to 9 "izza" and reverse it we obtain "paparazzi".

Editor Image

?