Getting partial marks

#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int *arr=new int[n];
for(int i=0;i<n;++i)
cin>>arr[i];

int s=0,e=0;
for(int i=1;i<n;++i)
{
    if(arr[i]==arr[i-1]+1)
    {
        e++;
    }
    else
    {
        if(e-s>=1)
        {
            cout<<arr[s]<<"->"<<arr[e]<<" ";
        }
        s=e=i;
    }
}
if(e-s>=1)
cout<<arr[s]<<"->"<<arr[e]<<" ";

return 0;
}

Hey @Harshrajotiya which test case number are you failing?

one and two …

Okay i got it, see for test case:
5
1 4 5 6 7
Expected output is this:
0->2 4->5 7
Yours is giving this:
4->7

Just consider this rest everything is fine in your code.

how 0->2 ? and also why 4->5 … the only continuous part is from 4 to 7 … i didnt get it

I am really sorry, i attached wrong test case, it should be
For test case:
6
0 1 2 4 5 7
Expected is: 0->2 4->5 7
Yours is givng:
0->2 4->5

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.