title: Largest sum of non-decreasing up sequence
body: <p>eg. -3,6,11,13,5,-11,4,7,8  largest sum =30 (6,11,13 cause adding -3 will make the sum smaller)</p>
  
  <p>eg. 7,0,-3                  largest sum = 7</p>
  
  <p>eg  4,-1,45                 largest sum = 45</p>
  
  <p>eg -3-,-2,-6,0              largest sum =0         </p>
  
  <p>Need some advise for my code, still buggy </p>
  
  <pre><code>    int maxSum = Integer.MIN_VALUE;
      int sum = 0;
      int checkNeg = Integer.MIN_VALUE;
  
      for (int i = 0; i &lt; a.length; i++) {
          if (a[i] &gt; checkNeg) {
              checkNeg = a[i];
          }
      }
  
      if (checkNeg &lt;= 0) {
          maxSum = checkNeg;
      }
  
      if (checkNeg &gt; 0) {
          for (int i = 0; i &lt; a.length; i++) {
              if (a[i] != 0) {
                  sum += a[i];
                  if (sum &gt; maxSum) {
                      if (i != 0) {
                          if (a[i] &gt;= a[i - 1]) {
                              maxSum = sum;
                          } else {
                              sum = a[i];
                          }
                      } else {
                          maxSum = sum;
                      }
                  }
                  if (sum &lt; 0) {
                      sum = 0;
                  }
              } else {
                  sum = 0;
              }
          }
      }
      return maxSum;
  </code></pre>