Question: write a code that solves the following problem : the answer code can be in c++ or java or python Problem#9 1) In this problem

write a code that solves the following problem :

the answer code can be in c++ or java or python

write a code that solves the following problem : the answer code

can be in c++ or java or python Problem#9 1) In this

Problem#9 1) In this problem you are given two type of query 1. Insert an integer to the list. 2. Given an integer x, you're about to find an integer k which represent x's index if the list is sorted in ascending order. Note that in this problem we will use 1-based indexing. As the problem title suggest, this problem intended to be solved using O(log (n)) for both insertion and getting X's index Input The first line contains an integer Q, which denotes how many queries that follows. The next Q lines will be one of the type queries which follow this format: 1 x means insert x to the list 2 x means find x's index if the list is sorted in ascending order. Output For each query type 2, print a line containing an integer as the answer or print"-1" no quotes if the requested number does not exist in the current list Input Example: 10 1 100 174 2 100 2 70 1 152 121 133 2 100 221 21 Output: 2-141-1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!