Hi All,
I was trying to solve one problem so written a below solution for that.
Problem :
Given a non-negative number represented as an array of digits,
add 1 to the number ( increment the number represented by the digits ).
The digits are stored such that the most significant digit is at the head of the list.
When I compiled the below code it compiled successfully.
But when I ran it getting bellow error:
I think you will have a problem with an array containing only '0's. You will end up deleting all of the elements in your array and then trying to access the value contained in the A.end()--, which is probably just A.end().
Since we don't know what values you passed into your function, it's hard to diagnose run-time errors.
@OP If you are then why don't you submit a small and complete tester that incorporates your post above. What you have so far is like saying to a mechanic 'I've got something wrong with my car, it won't go. Here's the steering wheel.' :)
OP: doug4 gave you a pretty succinct summary of what was going wrong in your attempt and that's the reason I'd mentioned checking for size 0 in my post.