Which data structure can solve this problem?

Revision en1, by definitely_not_bu1th4nh, 2018-11-30 07:18:13

Hi there, I have this problem: Given an array A of integers. You need to operate three kinds of query:

  • Insert an element X at position i in the array
  • Delete element at position i in the array
  • Answer the maximum element and the index of maximum element in range [l, r]

Constraints:

  • Q = number of queries — less than or equal 100000
  • N = number of elements — less than or equal 100000
  • X, A[i] is less than or equal 1000000000

I don't know which data structure is the most suitable for solving this problem. Can you help me with this and explain how to use that data structure?

Thank you.

Tags #advance data structures, #data structure, #tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English definitely_not_bu1th4nh 2018-11-30 10:34:20 49 Tiny change: 'y problem.' -> 'y problem.\n\n**UPD2:** I've added tags for the blog entry.'
en2 English definitely_not_bu1th4nh 2018-11-30 10:20:01 49
en1 English definitely_not_bu1th4nh 2018-11-30 07:18:13 686 Initial revision (published)