Skip to content

Instantly share code, notes, and snippets.

View GuillaumeTong's full-sized avatar

GuillaumeTong

View GitHub Profile
@GuillaumeTong
GuillaumeTong / answer1.py
Last active March 5, 2020 10:08
Oursky Developer Pre-Test 2020
# this function expects array1 and array2 to be iterables containing capital letter characters
def isSubset(array1, array2):
hashtable = dict.fromkeys(array1, True)
for x in array2:
if not hashtable.__contains__(x):
return False
return True
# # By using dict to store array1, we can get hashtable key lookup performance, which is O(1). Based on this,
# # the complexity of the function is overall O(n), as both array1 and array2 are only traversed once, and only an O(1)