Skip to content

Commit a9f1c1f

Browse files
committed
Time: 7 ms (85%), Space: 45.8 MB (10%) - LeetHub
1 parent f3a78e5 commit a9f1c1f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
fun canBeEqual(target: IntArray, arr: IntArray): Boolean {
3+
val map = mutableMapOf<Int, Int>()
4+
for(num in target){
5+
map[num] = map.getOrDefault(num, 0) + 1
6+
}
7+
for(num in arr){
8+
val count = map[num] ?: return false
9+
if(count == 0) return false
10+
map[num] = count - 1
11+
}
12+
13+
return true
14+
}
15+
}

0 commit comments

Comments
 (0)