Skip to content

Commit 5acc166

Browse files
authored
Create 1460. Make Two Arrays Equal by Reversing Subarrays (#545)
2 parents 42efe97 + 33cd804 commit 5acc166

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
bool canBeEqual(vector<int>& target, vector<int>& arr) {
4+
unordered_map<int,int>hash_target;
5+
unordered_map<int,int>hash_arr;
6+
int N = target.size();
7+
for (int i=0; i < N; i++) {
8+
hash_target[target[i]]++;
9+
hash_arr[arr[i]]++;
10+
}
11+
return hash_target == hash_arr;
12+
}
13+
};

0 commit comments

Comments
 (0)