Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The computational complexity of my answer in Question 1 is O(n^2)
- def isSubsetArray(ArrayA, ArrayB):
- countSameSubset = 0 # 1 Step
- for i_index in range(len(ArrayB)): # n Step
- for j_index in range(len(ArrayA)): # n Step
- if (ArrayA[j_index].strip().upper() == ArrayB[i_index].strip().upper()): # 1 Step
- countSameSubset += 1 # 1 Step
- break # 1 Step
- if (countSameSubset == len(ArrayB)): # 1 Step
- return True # 1 Step
- else:
- return False # 1 Step
- def main():
- StringA = input("Input the 1st Array : ") # 1 Step
- StringB = input("Input the 2nd Array : ") # 1 Step
- isSubsetValue = isSubsetArray(StringA.split(','), StringB.split(',')) # 1 Step
- print('isSubset([',StringB.upper(),'], [', StringA.upper(), ']) = ', str(isSubsetValue)) # 1 Step
- if __name__ == '__main__':
- main() # 1 Step
- # Because the comlexity time on line 5 is n Step and on line 6 is also n Step, so my computational complexity of my answer in Question 1 is O(n^2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement