Online Assessment Question!!
Anonymous User
792

A candlestick is a type of price chart used in technical analysis that displays the high, low, open and closing prices of Candlesticks reflect the impact of investor sentiment on security prices and are used by technical analysts to determine when to enter and exit trades.
We have been given an array of distinct positive integers called as prices. Each integer in the array denoted by prices[i] represents the high price in the candlestick.
You have to connect two candlesticks in such a way that all the candlesticks between them have a height smaller than the minimum height of the two. The task is to find the total number of pairs of such candlesticks.

Const:
2 <= Size(prices) <= 106
1 <= pricesi <= 109

eg:
5
10 3 4 8 6
output - 6
N = 5
prices = [10, 3, 4, 8, 6]
The pairs which satisfies the criteria are
(10, 3), (3, 4)
(4, 8), (10, 4)
(10, 8), (8, 6)

eg2:
4
2 80 4 32

output - 4

Comments (3)