Finding Maximum Value in an array

前端 未结 3 1195
轮回少年
轮回少年 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:46

    Create a tree structure upon the array. In each node keep the range and maximum of the subtree. On removing/inserting update the maximum in affected nodes bottom-up.

提交回复
热议问题