Last active
May 23, 2019 07:31
-
-
Save martin-mok/dba50e1d5d5845c68ca18015beb406b4 to your computer and use it in GitHub Desktop.
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
def isSubset(A,B): | |
""" | |
takes two arrays as input, each array contains a list of A-Z; | |
return True if all the elements in 2nd array is also in 1st array, or False if not. | |
""" | |
for i in range(len(B)): | |
found=False | |
for j in range(len(A)): #check if each character of B is found in A | |
if B[i] == A[j]: | |
found=True | |
break | |
if(not found): return False #one character of B is not in A found | |
return True #all character of B is in A | |
""" | |
Time Complexity: O(n^2) | |
2 loops | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment