Posts

Coding Solutions - Easy

  Array Missing element from a duplicated array # Find the missing element from the given 2 arrays, second array is duplicate. #array 1: [1,2,3,4,5,6,7] #array2: [1,3,4,5,6,7]  missing is 2 # Can I assume missing element is always from the second array? # assume only element is missing and its always present in the first array, if not present can i just return NULL element or something # So to confirm my fucntion takes two arrays of integers ?? as inputs and returns missing element or NULL # it does not matter its integer array or any other type of array # Appears from the input that array is sorted ? is it so? a1 = [1,2,3,4,5,6,7] a2 = [1,3,4,5,6,7] # special cases -  # first element could be missing or last element, no element missing # compare the length of two arrays, check for empty array def find_missing_element (a1, a2) :     missing_element = None     l1 = len(a1)     l2 = len(a2) # o(1) stil     if a1 is None or a2 is...