Home > other >  Maximum container
Maximum container

Time:09-26

A container, in the process of application are data into, at the top of the container at the end of the container to delete, how to seek after each operation (insert, delete) the biggest data values in the container? (can't use times calendar calculation method, the complexity of O (1), it is best to stack solution) end in delete easy to solve, end insert, delete side how to solve?

CodePudding user response:

With an auxiliary stack

CodePudding user response:

End in good solve: as long as the record inserted value is biggest, is a record is updated, not, just keep the original maximum;
Delete at one end is not good solution: if you remove the just right is one of the biggest, the remaining elements which is the biggest? Didn't know it,

Can think of is separate to make an order queue, insert and delete all synchronous update this queue,
  • Related