Stock buy and sell
Submissions: 37078   Accuracy:

30.43%

  Difficulty: Medium   Marks: 4

The cost of stock on each day is given in an array A. Find all the days on which you buy and sell the stock so that in between those days you shouldn't have any loss.

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

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

Constraints:
1 <= T <= 100
2 <= N <= 103
1 <= Ai <= 104

Example
Input:

2
7
100 180 260 310 40 535 695
10
23 13 25 29 33 19 34 45 65 67

Output:
(0 3) (4 6)
(1 4) (5 9)

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 **

Author: atharv


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

to report an issue on this page.