Skip to content

Commit e86340a

Browse files
committed
D. J.:
- Added the leetcode problem and solution for 2215
1 parent e27c1e8 commit e86340a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
- [1922 Count Good Numbers](https://leetcode.com/problems/count-good-numbers/description/)
268268
- [1964 Find the Longest Valid Obstacle Course at Each Position](https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position/description/)
269269
- [2140 Solving Questions With Brainpower](https://leetcode.com/problems/solving-questions-with-brainpower/description/)
270+
- [2215 Find the Difference of Two Arrays](https://leetcode.com/problems/find-the-difference-of-two-arrays/description/)
270271
- [2390 Removing Stars From a String](https://leetcode.com/problems/removing-stars-from-a-string/description/)
271272
- [2466 Count Ways To Build Good Strings](https://leetcode.com/problems/count-ways-to-build-good-strings/description/)
272273
- [2523 Closest Prime Numbers in Range](https://leetcode.com/problems/closest-prime-numbers-in-range/description/)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
"""Base class for all LeetCode Problems."""
6+
7+
def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:
8+
"""
9+
Given two 0-indexed integer arrays nums1 and nums2, return a list answer of
10+
size 2 where:
11+
- answer[0] is a list of all distinct integers in nums1 which are not present
12+
in nums2.
13+
- answer[1] is a list of all distinct integers in nums2 which are not present
14+
in nums1.
15+
16+
Note that the integers in the lists may be returned in any order.
17+
"""
18+
return [
19+
list(set(nums1).difference(set(nums2))),
20+
list(set(nums2).difference(set(nums1))),
21+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import List
2+
3+
import pytest
4+
5+
from awesome_python_leetcode._2215_find_the_difference_of_two_arrays import Solution
6+
7+
8+
@pytest.mark.parametrize(
9+
argnames=["nums1", "nums2", "expected"],
10+
argvalues=[
11+
([1, 2, 3], [2, 4, 6], [[1, 3], [4, 6]]),
12+
([1, 2, 3, 3], [1, 1, 2, 2], [[3], []]),
13+
],
14+
)
15+
def test_func(nums1: List[int], nums2: List[int], expected: List[List[int]]):
16+
"""Tests the solution of a LeetCode problem."""
17+
diff = Solution().findDifference(nums1, nums2)
18+
assert diff == expected

0 commit comments

Comments
 (0)