2013年3月7日
摘要: Examples: { -100, 1, 2, 3, -20, -20, -20, 2, 2, 2, 2,-100 }; Answer: 8{ 1,2,3}; Answer: 6{ -1,-2,-3}; Answer: -1Solution:O(n) Solution is to use dynamic programming. You can add numbers as you walk the array in the following manner:X[i]=X[i]+X[i-1];So, at each step X[i] would contain the sum of all 阅读全文
posted @ 2013-03-07 22:07 武胜-阿伟 阅读(174) 评论(0) 推荐(0) 编辑