2016-07-31 craneyuan
问题描述 在长度为N的整形数组中,求连续子串的和的最大值。 例如:1 2 4 5 -11 5 -3,结果为6。 注意:要考虑到数组中元素都为负数的情况。 O(n)解法 java public static int maxSubSum(int[] a) { int maxSum = a[0]; int curSum = 0; for (int j = 0; j < a.length; j++) { curSum += a[j]; if (curSum > maxSum) { maxSum = curSum; } else if ( 继续阅读 »
2016-08-29 ruki
New features Add wait multi-processes interface Add uuid generator Add hash library module Add __tb_deprecated__ keyword and option Changes Move some utils interfaces to the hash module Rewrite random generator Bugs fixed Fix stdout compatibility issue for vs2015 Fix process arguments length limit 继续阅读 »
2016-09-16 徐哲
冒泡排序 原理主要是倒序比较 代码如下: java class Untitled { public static void sortMaxMin(int array[]){ int i,j; int len = array.length; int temp; //Boolean flag = true; for (i = 0;ii;j--) { if (array[j-1]>array[j]) { temp = array[j]; 继续阅读 »
2015-06-15 W.Y.
ES6
如何遍历一个数组的元素?在 20 年前,当 JavaScript 出现时,你也许会这样做: javascript for (var index = 0; index < myArray.length; index++) { console.log(myArray[index]); } 自从 ES5 开始,你可以使用内置的 forEach 方法: javascript myArray.forEach(function (value) { console.log(value); }); 代码更为精简,但有一个小缺点:不能使用 break 语句来跳出循环,也不能使用 return 语句来从闭包函数中返回。 如果有 for 继续阅读 »