Last active
March 18, 2019 12:32
-
-
Save artisandhq/dc6868638b01b21580ab14037a5117e2 to your computer and use it in GitHub Desktop.
Question 1 (Write a function that takes two arrays as input, each array contains a list of A-Z; Your program should return True if the 2nd array is a subset of 1st array, or False if not.)
This file contains hidden or 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(arr1, arr2): | |
count = 0 | |
flagSubset = False | |
for i in range(len(arr2)): | |
for j in range(len(arr1)): | |
if(arr2[i].strip().upper() == arr1[j].strip().upper()): | |
count+=1 | |
break | |
if(count == len(arr2)): | |
flagSubset = True | |
return flagSubset | |
def main(): | |
arr1 = input("Input First Array (separate the letters with comma): ") | |
arr2 = input("Input Second Array(separate the letters with comma): ") | |
flagSubset = isSubset(arr1.split(","), arr2.split(",")) | |
print("isSubset([" + arr1 + "], [" + arr2 + "]) = " + str(flagSubset)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment