For this Question: The cost of stock on each day is given in an array A[] of size N. You can either buy or sell a stock on a particular day. You need to sell the previous stock before buying a new one. Find all the days on which you buy and sell the stock so that in between those days your profit is maximum.

There are no two days with same price of the stock.

See sample for a better explanation.First-line contains an integer value N denoting the number of days, followed by an array of stock prices of N days.

Constraints:
1 <= N <= 10^5
1 <= A[i] <= 10^6For each array of input, print an output with a pair of integers (a, b) where a represents day to buy stock and b represents day of selling stock. Output may contain of more than one pair, print them in all seperate line(assume 0 base indexing).

For no profit, print null.Input:
7
100 180 260 310 40 535 695

Output:
0 3
4 6

Input:
5
68 45 40 12 6

Output:
null

Explanations:-
Testcase1:- For range 0 to 3 the cost of stock is increasing so it is profitable to buy the stock at index 0 and sell it at index 3 same for range 4 to 6, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];

}
int cnt=0;
vector<int> v;
for(int i=0;i<n-1;i++){
    if(a[i+1]>a[i]){
            if(cnt==0){v.push_back(i);}
            cnt++;}
    else{if(cnt!=0){
    v.push_back(i);}cnt=0;}
}

if(a[n-1]>a[n-2]){v.push_back(n-1);}
if(v.size()==0){cout<<"null";return 0;}
for(int i=0;i<v.size();i+=2){
        cout<<v[i]<<" ";
cout<<v[i+1]<<endl;

}

}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?