Not getting the answer while submitting please Help!!!
Here is my code
At least one problem (not the only one!) is that the array a
is uninitialised so may contain lots of random stuff (as well as values from previous testcases) - it should be cleared before reading in new data.
Edit:
I recommend running your code locally with the example input from the problem. Add some diagnostics to your code (but remember to remove them when you are ready to Submit your solution!). In particular, print out the values of “sum”, “h”, and “l” after the line
sum = sum + h-l+1;
Do they look correct? If not, why not?