Skip to content

Commit 89c5051

Browse files
solves intersection of 2 arrays in python
1 parent b8ee264 commit 89c5051

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
| 344 | [Reverse A String](https://leetcode.com/problems/reverse-string) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/ReverseString.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/reverse_a_string.py) |
9898
| 345 | [Reverse Vowels of A String](https://leetcode.com/problems/reverse-vowels-of-a-string) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/ReverseVowelsOfString.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/reverse_vowels_of_a_string.py) |
9999
| 346 | 🔒 [Moving Average From Data Stream](https://leetcode.com/problems/moving-average-from-data-stream) | Easy | |
100-
| 349 | [Intersection of 2 Arrays](https://leetcode.com/problems/intersection-of-two-arrays) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/IntersectionOfTwoArrays.java) |
100+
| 349 | [Intersection of 2 Arrays](https://leetcode.com/problems/intersection-of-two-arrays) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/IntersectionOfTwoArrays.java) [![Python](https://img.icons8.com/color/35/000000/python.png)](python/intersection_of_2_array.py) |
101101
| 350 | [Intersection of 2 Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/IntersectionOfTwoArraysII.java) |
102102
| 359 | [Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter) | Easy | |
103103
| 367 | [Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square) | Easy | [![Java](https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png)](https://github.com/anishLearnsToCode/leetcode-algorithms/blob/master/src/IsPerfectSquare.java) |

python/intersection_of_2_array.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
6+
nums_1_unique = set(nums1)
7+
nums_2_unique = set(nums2)
8+
return list(nums_1_unique.intersection(nums_2_unique))

0 commit comments

Comments
 (0)