FunctionRacerProblemsRace

Make Two Arrays Equal

EasySorting and searchingPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Sorting and searching problems