1+ '''
2+ Given two integer arrays of equal length target and arr.
3+
4+ In one step, you can select any non-empty sub-array of arr and reverse it. You are allowed to make any number of steps.
5+
6+ Return True if you can make arr equal to target, or False otherwise.
7+
8+
9+
10+ Example 1:
11+
12+ Input: target = [1,2,3,4], arr = [2,4,1,3]
13+ Output: true
14+ Explanation: You can follow the next steps to convert arr to target:
15+ 1- Reverse sub-array [2,4,1], arr becomes [1,4,2,3]
16+ 2- Reverse sub-array [4,2], arr becomes [1,2,4,3]
17+ 3- Reverse sub-array [4,3], arr becomes [1,2,3,4]
18+ There are multiple ways to convert arr to target, this is not the only way to do so.
19+ Example 2:
20+
21+ Input: target = [7], arr = [7]
22+ Output: true
23+ Explanation: arr is equal to target without any reverses.
24+ Example 3:
25+
26+ Input: target = [1,12], arr = [12,1]
27+ Output: true
28+ Example 4:
29+
30+ Input: target = [3,7,9], arr = [3,7,11]
31+ Output: false
32+ Explanation: arr doesn't have value 9 and it can never be converted to target.
33+ Example 5:
34+
35+ Input: target = [1,1,1,1,1], arr = [1,1,1,1,1]
36+ Output: true
37+ '''
38+ class Solution :
39+ def canBeEqual (self , target : List [int ], arr : List [int ]) -> bool :
40+ return sorted (arr ) == sorted (target )
0 commit comments