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
function canMadeEqual ( A , B , n ) { A . sort ( ) ; B . sort ( ) ; for ( var i = 0 ; i < n ; i ++ ) if ( A [ i ] != B [ i ] ) return false ; return true ; } var A = [ 1 , 2 , 3 ] ; var B = [ 1 , 3 , 2 ] ; var n = A . length ; if ( canMadeEqual ( A , B , n ) ) document . write ( " " ) ; else document . write ( " " ) ;