2.4.2

question:

Criticize the following idea: To implement find the maximum in constant time, why not use a stack or a queue, but keep track of the maximum value inserted so far, then return that value for find the maximum?

answer:

//不只找这一个最大值,在执行删除最大值之后还是要找下一个最大值的

//官网答案

Solution. Will need to update the maximum value from scratch after a remove-the-maximum operation.

猜你喜欢

转载自www.cnblogs.com/w-j-c/p/9135500.html