Timer is Running

The cost of stock on each day is given in an array A[] of size N. Find all the days on which you buy and sell the stock so that in between those days your profit is maximum.

First line contains number of test cases T. First line of each test case contains an integer value N denoting the number of days, followed by an array of stock prices of N days. 

For each testcase, output all the days with profit in a single line. And if there is no profit then print "No Profit".

1 <= T <= 100
2 <= N <= 103
0 <= Ai <= 104


100 180 260 310 40 535 695

100 50 30 20
23 13 25 29 33 19 34 45 65 67

(0 3) (4 6)
No Profit
(1 4) (5 9)

Testcase 1:
We can buy stock on day 0, and sell it on 3rd day, which will give us maximum profit.

Note: Output format is as follows - (buy_day sell_day) (buy_day sell_day)
For each input, output should be in a single line.


** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: atharv

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.