Here we are asked to write an algorithm having linear and logrithmic time complexities , but given that the string can be anywhere (in any row/column) we are bound to search in the whole dataset . Also we cannot sort the dataset since it will get distorted.
Hi @jfpsmatos,
I think your solution still has a quadratic complexity because ‘in’ operator within Python still has to perform search and compare each letter in the joined row.
Based on the string content ‘LAX94LA336’, we can say it corresponds to ‘Accident Number’ column. Knowing this makes our search linear:
lax_code = []
for row in aviation_list:
if row[2]=='LAX94LA336':
lax_code.append(row)