Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

help needed in a DP question.

$
0
0

given two arrays, of which one is increasing (not necessary strictly) and other is decreasing(strictly actually it is the index of that element from back)and we have to answer q queries [x, y] in which we have to find the maximum value of the product of the value at same indices in array excluding the given range [x, y].

Example :

a1 : 1 2 2 3 4 (fixed increasing array)

a2 : 4 0 3 2 1 (for range [1, 1]) : answer is 6 (32 or 23)

a2 : 2 0 0 0 1 (for range [1, 3]) : answer is 4 (4*1)

I thought of applying binary search but as the first array is not strictly increasing it fails!


Viewing all articles
Browse latest Browse all 39796

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>