赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 2 3 4 5 6 ··· 11 下一页

2013年6月24日

摘要: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).解题思路:该题可以解决所有求有序数组A和B有序合并之后第k小的数!该题的重要结论:如果A[k/2-1] n) return findKth(B, n, A, m, k); if (m == 0) return B[k... 阅读全文
posted @ 2013-06-24 21:02 赵乐ACM 阅读(9888) 评论(0) 推荐(0) 编辑

摘要: 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 target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are 阅读全文
posted @ 2013-06-24 17:52 赵乐ACM 阅读(11300) 评论(6) 推荐(1) 编辑

2013年4月9日

摘要: 平时用linux时,我有一个习惯就是把遇到的,比较有用,并且容易忘的命令,放到一个文本文件中,没事的时候可以拿出来看看,这样可以加深印象,时间长了这些命令的用法基本上都能掌握了。以下是100个用法,有什么不对,还请大家指正。1,echo "aa" > test.txt 和 echo "bb" >> test.txt //>将原文件清空,并且内容写入到文件中,>>将内容放到文件的尾部2,chmod go+w -R/home/zhangy//给组用户和其他用户添加写的权限3,tar -tzvf test.tar.gz // 阅读全文
posted @ 2013-04-09 17:15 赵乐ACM 阅读(504) 评论(0) 推荐(0) 编辑

2013年3月23日

摘要: 1. python中的继承class Parent(object): def override(self): print "PARENT override()" def implicit(self): print "PARENT implicit()" def altered(self): print "PARENT altered()"class Child(Parent): def override(self): print "CHILD override()" def altered(self): ... 阅读全文
posted @ 2013-03-23 21:50 赵乐ACM 阅读(157) 评论(0) 推荐(0) 编辑

2013年3月22日

摘要: 1. 今天学了一些概念。(书的第41~43章)用这个方法可以分清楚class、object、instance## Animal is-a object (yes, sort of confusing) look at the extra creditclass Animal(object): pass## Dog is-a animal, it has-a nameclass Dog(Animal): def __init__(self, name): ## ?? self.name = name## Cat is-a animal, it has-a ... 阅读全文
posted @ 2013-03-22 22:42 赵乐ACM 阅读(176) 评论(0) 推荐(0) 编辑

2013年3月21日

摘要: 1. list相关的有一个比较有趣的问题,就是mystuff.append('hello'),python是怎么解释的。这里有段话讲的比较清楚,就不翻译了,直接贴过来。Python sees you mentionedmystuffand looks up that variable. It might have to look backwards to see if you created with=, look and see if it is a function argument, or maybe it's a global variable. Either 阅读全文
posted @ 2013-03-21 21:27 赵乐ACM 阅读(900) 评论(0) 推荐(0) 编辑

2013年3月20日

摘要: 1. 整理python的关键字# _*_ coding:utf-8 _*_anddel #删除list中的某个元素或者这个list,同样适用于字典fromnotwhileaselifglobalorwith #http://www.cnblogs.com/Brogrammer/archive/2012/07/23/2605570.htmlassert #assert语句用来声明某个条件是真的。例如,如果你非常确信某个你使用的列表中至少有一个元素,而你想要检验这一点,并且在它非真的时候引发一个错误,那么assert语句是应用在这种情形下的理想语句。当assert语句失败的时候,会引发一个Asse 阅读全文
posted @ 2013-03-20 22:43 赵乐ACM 阅读(153) 评论(0) 推荐(0) 编辑

2013年3月19日

摘要: 1. list比较熟悉了,但是list的函数们还不清楚,参考http://docs.python.org/2/tutorial/datastructures.html2. for和while经验是尽量少用while,因为while出错的机会大。3. 综合起来写的一个小程序from sys import exitdef gold_room(): print "This room is full of gold. How much do you take?" next = raw_input("> ") if "0" in next 阅读全文
posted @ 2013-03-19 18:27 赵乐ACM 阅读(294) 评论(0) 推荐(0) 编辑

2013年3月18日

摘要: 1. Django如何新建一个网站python django-admin.py startproject mysite在mysite文件夹下会生成如下文件:mysite/ manage.py mysite/ settings.py urls.py __init__.py wsgi.py启动网站python manage.py runserverpython manage.py runserver 8080 #修改端口号,默认的是8000python manage.py runserver 0.0.0.0:8000 #告诉服务器... 阅读全文
posted @ 2013-03-18 21:13 赵乐ACM 阅读(1481) 评论(0) 推荐(0) 编辑

摘要: 整理的一些符号(前三个在java和c中是不这样表达的,用&&、||、!表达)andornot!=(not equal)==(equal)>=(greater-than-equal)<=(less-than-equal)TrueFalseView Code # _*_ coding:utf-8 _*_print (True and False), Falseprint (False and True), Falseprint (1 == 1 and 2 == 1), Falseprint ("test" == "test"), 阅读全文
posted @ 2013-03-18 11:32 赵乐ACM 阅读(237) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 11 下一页