Question

You have a list of numbers and need to find the maximum value. Which of the following approaches would be the most efficient in terms of time complexity?

A Sort the list and take the last element.
B Iterate through the list once, keeping track of the maximum seen so far.
C Use a binary search tree to store elements and find the maximum.
D Use a hash map to store elements and find the maximum.
E Recursively divide the list into halves until a single element remains.
Practice Next

Hey! Ask a query