Description
Given two integer arrays target and arr, return true if you can make arr equal to target by reversing any subarray of arr any number of times.
Examples
Input:
target = [1,2,3,4], arr = [2,4,1,3]Output:
trueExplanation:
Can rearrange to match.
Input:
target = [7], arr = [7]Output:
trueExplanation:
Both arrays are identical with a single element [7].
Input:
target = [3,7,9], arr = [3,7,11]Output:
falseExplanation:
arr contains 11 which is not in target (which has 9). Reversing subarrays cannot change element values.
Constraints
- •
1 ≤ target.length ≤ 1000