Created
November 9, 2018 12:07
-
-
Save john012343210/46a0c1f6d6bcc800130580fcb2122fda to your computer and use it in GitHub Desktop.
Check whether the alphabetical array is a subset of another alphabetical array. RUNNING TIME O(n)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
def isSubset(arr1,arr2): | |
d = dict.fromkeys(string.ascii_lowercase, 0) | |
for i in arr1: | |
d[i]+=1 | |
for j in arr2: | |
if d[j] == 0: | |
return False | |
return True | |
print(isSubset(['a','b','c'],['c','b','z'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment