Finding Maximum Value in an array

前端 未结 3 1219
轮回少年
轮回少年 2021-01-25 18:32

One thousand(1000) elements are entered into an array (no memory constraints). As we know, while entering the elements we can update the max out of entered values by a check whe

3条回答
  •  忘了有多久
    2021-01-25 18:54

    You should use max heap data structure. The property of max-heap is that you can get the max value in O(1) time. Whereas each insertion and deletion will take O(log(n)) time. For more info check here

提交回复
热议问题