Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 075fa73

Browse files
a-khakimova.khakimov
authored and
a.khakimov
committed
2215. Find the Difference of Two Arrays
1 parent f128818 commit 075fa73

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Solution {
2+
def findDifference(nums1: Array[Int], nums2: Array[Int]): List[List[Int]] = {
3+
val s1 = nums1.toSet
4+
val s2 = nums2.toSet
5+
List(s1.diff(s2).toList, s2.diff(s1).toList)
6+
}
7+
}
8+
9+
Solution.findDifference(Array(1,2,3), Array(2,4,6))
10+
Solution.findDifference(Array(1,2,3,3), Array(1,1,2,2))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Hash Map / Set
2+
3+
Задачи, связанные с Hash Map и Hash Set, обычно требуют работы с хэш-таблицами (ассоциативными массивами) или хэш-наборами для эффективного хранения и поиска данных. Эти структуры данных обеспечивают доступ за O(1) для операций вставки, удаления и проверки наличия элемента, что делает их удобными для задач, связанных с подсчетом, сопоставлением и проверкой уникальности.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /