These kind of errors are caused by the following:
Forgetting that an index is zero-based and assuming it begins at 1. This typically affects arrays and strings.
Enumerating through a range of values and testing for equality with the target value rather than testing that you are still less than the target value. This is typically a problem when you build for loops.