Make Two Arrays Equal by Reversing Subarrays Problem
Make Two Arrays Equal by Reversing Subarrays Problem — ExecCode Easy DSA Practice
Solve the Make Two Arrays Equal by Reversing Subarrays problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given two integer arrays of equal length target and arr. Your task is to compute the required answer and return true if you can make arr equal to target or false otherwise. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.
Examples
Input {"target": [4, 3, 2, 1], "arr": [1, 2, 3, 4]}; Output True. Input {"target": [5, 6, 7, 8], "arr": [8, 7, 6, 5]}; Output True. Input {"target": [1, 1, 1, 1], "arr": [1, 1, 1, 1]}; Output True
Constraints
target.length == arr.length 1 <= target.length <= 1000 1 <= target[i] <= 1000 1 <= arr[i] <= 1000
Practice Make Two Arrays Equal by Reversing Subarrays free on ExecCode. Browse DSA problems, topic map, and placement guides.