上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 33 下一页
摘要: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2016-04-30 03:47 周洋 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 找一下规律就发现,4的倍数都必败,其它都必胜。 阅读全文
posted @ 2016-04-30 03:42 周洋 阅读(264) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. to Trivia:This problem was inspired by this original tweet by Max Howell: 题解:很简单的递归。 阅读全文
posted @ 2016-04-30 02:42 周洋 阅读(338) 评论(0) 推荐(0) 编辑
摘要: 以下两点摘自:http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001431664106267f12e9bef7ee14cf6a8776a479bdec9b9000 1.对于单个字符的 阅读全文
posted @ 2016-04-29 03:01 周洋 阅读(2004) 评论(0) 推荐(0) 编辑
摘要: 读文件 打开一个文件用open()方法(open()返回一个文件对象,它是可迭代的): r表示是文本文件,rb是二进制文件。(这个mode参数默认值就是r) 如果文件不存在,open()函数就会抛出一个IOError的错误,并且给出错误码和详细的信息告诉你文件不存在: 文件使用完毕后必须关闭,因为文 阅读全文
posted @ 2016-04-28 01:44 周洋 阅读(384369) 评论(2) 推荐(15) 编辑
摘要: 1.sort() list类型有一个自带的排序函数sort() 参数说明: (1) cmp参数 cmp接受一个函数,来确定比较方式,默认的是: def f(a,b): return a-b 返回负数就是a<b。(升序) 所以我们如果要想按降序排序,可以这么定义cmp: list.sort(cmp=l 阅读全文
posted @ 2016-04-27 23:19 周洋 阅读(3722) 评论(0) 推荐(0) 编辑
摘要: enumerate函数用于遍历序列中的元素以及它们的下标,可以非常方便的遍历元素。 比如我在往excel中写数据时就用到了这个函数: 阅读全文
posted @ 2016-04-27 22:54 周洋 阅读(1526) 评论(0) 推荐(0) 编辑
摘要: bisect模块用于二分查找,非常方便。 Bisect模块提供的函数有: 1.查找 bisect.bisect_left(a,x, lo=0, hi=len(a)) : 查找在有序列表a中插入x的index。lo和hi用于指定列表的区间,默认是使用整个列表。 bisect.bisect_right( 阅读全文
posted @ 2016-04-26 23:55 周洋 阅读(1449) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 阅读全文
posted @ 2016-04-26 03:15 周洋 阅读(217) 评论(0) 推荐(0) 编辑
摘要: Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Given s 阅读全文
posted @ 2016-04-25 11:09 周洋 阅读(142) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 33 下一页