Skip to content

Commit ca51df0

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

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

C++/make-two-arrays-equal-by-reversing-sub-arrays.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ class Solution {
1616
return count;
1717
}
1818
};
19+
20+
// Time: O(nlogn)
21+
// Space: O(1)
22+
class Solution2 {
23+
public:
24+
bool canBeEqual(vector<int>& target, vector<int>& arr) {
25+
sort(begin(target), end(target));
26+
sort(begin(arr), end(arr));
27+
return target == arr;
28+
}
29+
};

0 commit comments

Comments
 (0)