Max Tree(LintCode 126):

Problem