maximum swap 数组当作hashmap用 数字和index对应,比当前数字大的数字们的indices 跟 当前数字的index比较 (从最大的开始), 一旦大的, 那就换 ...
分类:
其他好文 时间:
2017-09-20 10:32:24
阅读次数:
156
SFLA=SCE+PSO SCE: shuffled complex evolution algorithm(Duan 1992) = CRS(controlled radom search Price 1978)+Competive evolution(Holland 1975)+shufflin ...
分类:
编程语言 时间:
2017-09-19 20:22:48
阅读次数:
335
一、多线程实现方式 (1)继承Thread类,覆盖run方法 (2)实现Runnable接口,覆盖run方法,将对象传人Thread对象中 实现Runnable接口比继承Thread类所具有的优势: 1)适合多个相同的程序代码的线程去处理同一个资源 2)可以避免java中的单继承的限制 3)增加程序 ...
分类:
编程语言 时间:
2017-09-18 15:08:10
阅读次数:
218
原题链接在这里:https://leetcode.com/problems/maximum-average-subarray-i/description/ 题目: Given an array consisting of n integers, find the contiguous subarra ...
分类:
其他好文 时间:
2017-09-18 14:48:15
阅读次数:
148
题目大意: 给定一个01序列,支持以下两种操作: 1.区间反转; 2.区间求不同的子序列数量。 思路: 首先我们考虑区间反转,这是一个经典的线段树操作。 接下来考虑求不同的子序列数量,在已知当前区间的情况下,我们有如下$O(n)$的动态规划:| $f_{i,0}=f_{i-1,0}+f_{i-1,1 ...
分类:
其他好文 时间:
2017-09-18 14:43:42
阅读次数:
129
Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binar ...
分类:
其他好文 时间:
2017-09-18 01:18:26
阅读次数:
240
#week2# #from leetcode# Description Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For examp ...
分类:
其他好文 时间:
2017-09-18 00:18:48
阅读次数:
259
题目链接https://leetcode.com/submissions/detail/119156148/ 题目大意:返回一个二叉树的高度。 法一:深搜,左右子树直接递归(耗时1ms),代码如下: 1 private static int maxDepth(TreeNode root) { 2 i ...
分类:
其他好文 时间:
2017-09-17 22:06:10
阅读次数:
140
Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the ...
分类:
其他好文 时间:
2017-09-17 16:27:05
阅读次数:
116