You are given equal-length integer arrays target and arr. In one operation, choose a nonempty contiguous part of arr and reverse its order. You may repeat this operation any number of times, including zero. Return true if arr can become exactly equal to target, and false otherwise.
Example 1:
Input: target = [1,2,3]
arr = [3,2,1]
Output: trueExplanation: Reverse all three elements of arr to obtain [1,2,3], which matches target.
Example 2:
Input: target = [1,1,2]
arr = [1,2,2]
Output: falseExplanation: The arrays contain different numbers of 1s and 2s. Reversals only change positions, so they cannot make the arrays equal.
Example 3:
Input: target = [4]
arr = [4]
Output: trueExplanation: The arrays already match. No operation is needed.
Constraints:
1 <= target.length <= 1000target.length == arr.length1 <= target[i], arr[i] <= 1000