Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Name:Rosa Wu
- #Update date:2019.03.20
- #Problem statement:Determine two input array that whether second array is a subset of 1st array or not.
- def isSubset(array1,array2):
- a1 = array1.split(",")
- arraylen1 = len(array1)
- a2 = array2.split(",")
- arraylen2 = len(array2)
- data = dict()
- #Input all the 1st array char in dictionary.
- for i in range(arraylen1):
- data[array1[i]]=i
- #Check each char in 2nd array whether in dictionary or not.
- tf = 1
- for i in range(arraylen2):
- if(data.get(array2[i]) == None):
- print("false")
- tf = 0
- break
- if tf == 1:
- print("true")
- array1 = raw_input("array1 input:")
- array2 = raw_input("array2 input:")
- isSubset(array1,array2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement