Make Two Arrays Equal
You may reverse any contiguous stretch of arr as many times as you like. Return True if arr can be turned into target this way, otherwise False.
Hint: think about which orderings can be reached.
Example 1
target [1,2,3,4]
arr [2,4,1,3]
returns true
Both hold the same numbers, so yes.
Example 2
target [3,7,9]
arr [3,7,11]
returns false
9 is missing from arr.
Constraints
1 <= len(target) == len(arr) <= 300 <= values <= 20
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.