About the logic in the program

Can this qstn solved using the technique used in harvesting rainwater problem or can that problem be solved using stack?

Hey ,I dont think so it can be solved using that way .
If you have some approach in mind then tell me & I will tell you where it can fail.
And yes according to me the most optimized approach is using stacks only.

Idea is like creating 2 arrays that will maintain the leftmost smallest element index and the other array maintaining the rightmost smallest element index .Thn from there we can calculate area

Say array of prices is
100 80 60 70 60 75 85
then
Your first array will be
0 1 2 2 2 2 2
And second array will be
4 4 4 4 4 5 6
Now how will u proceed further?