Skip to content

Instantly share code, notes, and snippets.

@martin-mok
Last active May 23, 2019 07:31
Show Gist options
  • Save martin-mok/dba50e1d5d5845c68ca18015beb406b4 to your computer and use it in GitHub Desktop.
Save martin-mok/dba50e1d5d5845c68ca18015beb406b4 to your computer and use it in GitHub Desktop.
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