SpaceX Interview Question

write search algorithm to calculate the totals