Check if two arrays can be made equal by reversing subarrays multiple times | C # implementation to check if two arrays can be made equal ; 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
using System ; class GFG { static bool canMadeEqual ( int [ ] A , int [ ] B , int n ) { Array . Sort ( A ) ; Array . Sort ( B ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] != B [ i ] ) { return false ; } } return true ; } public static void Main ( ) { int [ ] A = { 1 , 2 , 3 } ; int [ ] B = { 1 , 3 , 2 } ; int n = A . Length ; if ( canMadeEqual ( A , B , n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }