Check if two arrays can be made equal by reversing subarrays multiple times | Function to check if array B can be made equal to array A ; Sort both the arrays ; Check if both the arrays are equal or not ; Driver Code
def canMadeEqual ( A , B , n ) : NEW_LINE INDENT A . sort ( ) NEW_LINE B . sort ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( A [ i ] != B [ i ] ) : NEW_LINE return False NEW_LINE DEDENT return True NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT A = [ 1 , 2 , 3 ] NEW_LINE B = [ 1 , 3 , 2 ] NEW_LINE n = len ( A ) NEW_LINE if ( canMadeEqual ( A , B , n ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT