• + 1 comment

    can you explain why it's (n+1) and not (n)?

    • + 0 comments

      The question asks for a 1 indexed list and the a,b values read in are read in starting from 1 not 0. If you do not use (n+1)if b happens to be the last number of your list it will go out of bounds.

      The 0 index value will always be 0 so it doesn't affect your answer when you sum for max difference.