Updated a correct O(N) solution to P18

Each node now holds a maximum summary up untill this point.