This algorithm question: sum of all contiguous sub-array’s max difference was closed as not a real question, when there are 3 different answers, each with the same interpretation, posted. Note: I am not the asker of the question! (I have posted an answer).
I really fail to understand what is unclear regarding this question. It is an algorithm question, and it is quite clear what OP is looking for: A better than quadratic algorithm for a well defined problem. So prior code is actually irrelevant, as OP is looking for a better algorithm.
It might sound like homework, and perhaps some details regarding the motivation are missing, but does that justify closing it as a not-a-real question?