Skip to content

Commit 6d2b557

Browse files
authored
Update make-two-arrays-equal-by-reversing-sub-arrays.py
1 parent c88c56b commit 6d2b557

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Python/make-two-arrays-equal-by-reversing-sub-arrays.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,16 @@ def canBeEqual(self, target, arr):
1212
:rtype: bool
1313
"""
1414
return collections.Counter(target) == collections.Counter(arr)
15+
16+
17+
# Time: O(nlogn)
18+
# Space: O(1)
19+
class Solution2(object):
20+
def canBeEqual(self, target, arr):
21+
"""
22+
:type target: List[int]
23+
:type arr: List[int]
24+
:rtype: bool
25+
"""
26+
target.sort(), arr.sort()
27+
return target == arr

0 commit comments

Comments
 (0)