We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think You can make a small improvement.
It was possible to create an array with n + 2 elements instead of n-1 elements and not use the operator "if".
change
1. "long int *a=new long int[N+1]();" to
"long int *a=new long int[N+2]();"
2. "if((q+1)<=N) a[q+1]-=sum;" to
"a[q+1]-=sum;"
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →