题目
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 numbers such that they add up to the...
分类:
其他好文 时间:
2014-06-18 12:05:44
阅读次数:
244
3 数据类型数据类型是一门语言里最基本的表达单元。如果数据类型越丰富,表达能力就越强,使用起来就越方便。当然,如果类型太多,就会导致难记,因此在类型丰富与记忆之间取得一个平衡点。Python内置了不少的数据类型,这样编写代码时,达到编写最少的代码,但需要记忆的时间就多一些了。Python语言在输入时并不需要指明变量的数据类型,它的类型是由编译器和运行时动态地识别出来,如果类型不能操作时,就会抛出异...
分类:
其他好文 时间:
2014-06-18 11:48:13
阅读次数:
136
魔法方法、属性和迭代器
在python中,有的名称会在前面和后面各加上两个下划线,这种写法很特别。它表示名字有特殊含义,所以绝不要在自己的程序中使用这种名字。在python中,由这些名字组成的集合所包含的方法叫做魔法(或称特殊)方法。如果对象实现了这些方法中的某一个,那么这个方法会在特殊的情况下被python调用,而几乎没有直接调用它们的必要。
准备工作
为了确保类是新型的,应该把赋值语句_...
分类:
编程语言 时间:
2014-06-18 11:47:00
阅读次数:
358
对京东某一商品信息页面的HTML代码进行分析,可以发现它的图书产品信息页面都含有这样一段代码(不同类的商品页面有些不同):
window.pageConfig={compatible:true,searchType: 1,product:{"skuid":"11408255","name":"\u4f17\u795e\u7684\u536b\u661f\uff1a\u4e2d\u56fd\u79...
分类:
编程语言 时间:
2014-06-18 11:20:32
阅读次数:
275
题目
Write a function to find the longest common prefix string amongst an array of strings.
方法
从第一个字符开始,判断是否相同。
public String longestCommonPrefix(String[] strs) {
if (strs ...
分类:
其他好文 时间:
2014-06-18 11:18:30
阅读次数:
205
主要基于colorsys实现,样例是从hls转换到rgb,ru...
分类:
编程语言 时间:
2014-06-17 22:35:14
阅读次数:
359
最简单的不相交集的实现,来自MAW的《数据结构与算法分析》。代码:class DisjSet: def __init__(self, NumSets): self.S = [0 for i in range(NumSets+1)] def SetUnion(self, S,...
分类:
编程语言 时间:
2014-06-17 15:17:56
阅读次数:
265
#!/usr/bin/pythonimport tracebacktry: 1/0#except Exception,e:# print traceback.format_exc() except Exception as e: print e#!/usr/bin/pythonimport tra....
分类:
编程语言 时间:
2014-06-17 15:07:08
阅读次数:
329
";}file_exists("abx.txt") or die("文件不存在");echo "文件存在";*/// 自定义错误//感觉比较窄,扩展性不好,/* function myerror_1($errorno,$errmes){echo $errorno."错误";echo "info:"....
分类:
Web程序 时间:
2014-06-17 14:58:11
阅读次数:
216
今天遇到一个问题,在使用jquery的$.post()方法时,没有办法返回布尔值。function check_exist() { var email = $('#email').val().Trim(); url = "/Acco...
分类:
Web程序 时间:
2014-06-17 14:53:51
阅读次数:
868