前段时间在读trac中wiki模块的源码的时候,发现了很多地方都使用了yiled这一关键词,感觉是在需要返回某个值的地方通过yield来代替return,不是很明白其用法,所以仔细研究下。一个使用了yiled关键字的函数就不再是一个普通的函数了,而是一个生成器函数(generator functio...
分类:
编程语言 时间:
2014-10-10 18:06:04
阅读次数:
231
public class jiaoji { /** * @param args */ public static void main(String[] args) { String s1="abc"; String s2="abdgca"; System.out.println...
分类:
其他好文 时间:
2014-10-10 17:36:24
阅读次数:
164
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2014-10-10 16:26:13
阅读次数:
141
public class shuzujizaihouzhiqian { //private static final String[][] String = null; /** * @param args * @return */ public static void sort(int[]...
分类:
编程语言 时间:
2014-10-10 16:08:50
阅读次数:
169
这里的函数主要用来做:检查操作。参考资料为quick_cocos.星月倾心贡献~~~--[[-- 检查并转换为数值,转换失败则返回 0-- @param value 要检查并转换的值-- @param base 进制,默认为十进制-- @return number 返回的数值--]]function...
分类:
其他好文 时间:
2014-10-10 15:59:00
阅读次数:
153
[leetcode]Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order....
分类:
其他好文 时间:
2014-10-10 15:11:54
阅读次数:
139
题目:有一颗满二叉树,每个节点是一个开关,初始全是关闭的,小球从顶点落下,
小球每次经过开关就会把它的状态置反,现在问第k个球下落到d层时经过的开关编号。
分析:进制编码。经过模拟几次可以看出,球会让开关形成连续二进制数的表示(根是低位)。
当放入第k个球时,开关状态正好是二进制的k,利用模2的余数判断走向即可。
说明:观察规律模拟处理即可。...
分类:
其他好文 时间:
2014-10-10 15:02:02
阅读次数:
233
/**
* 字母
* @author stone
*
*/
public class Letter {
private String name;
public Letter(String name) {
this.name = name;
}
public String getName() {
return name;
}
}/**
* 一个产生字母对象的 享元工...
分类:
编程语言 时间:
2014-10-10 14:46:14
阅读次数:
182
public class mylin { /** * @param args */ public static void main(String[] args) { int n1 = 0; int n2 = 0; for (int i = 123; i ...
分类:
其他好文 时间:
2014-10-10 14:33:04
阅读次数:
158
这题看起来挺简单的,就是存一个哈希表,然后依次遍历整个字符串,遇到前面有过的字符的时候,就该停止当前计数,新的子串应该从发现该字符的位置的下一位置开始。我开始写了一个简单的写法,发现超时了: if (s.empty()) return 0; if (s.length() == 1) retur.....
分类:
其他好文 时间:
2014-10-10 14:28:10
阅读次数:
160