- 博客(11)
- 收藏
- 关注
原创 Leetcode 391. Perfect Rectangle
题目链接 Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region. Each rectangle is represented as a bottom-left point and a top-r...
2018-04-28 22:58:12 213
原创 究竟什么是冯诺依曼瓶颈(von Neumann Bottleneck)?
先看一下冯诺依曼结构: 再看一下冯诺依曼结构的“对头”——哈佛结构: 可以看到两者的主要差别是冯诺依曼架构不区分数据与指令,将两者放在同一内存中;而哈佛结构将两者分别存放在Instruction Memory和Data Memory。 指令和数据放在一起的后果是取指令和取数据不能同时进行,否则会引起访存的混乱。发展到今天,CPU的运算速度已经远远超过了访存速度,因此CPU必须浪费时间...
2018-04-18 23:23:41 24735
原创 Leetcode 148. Sort List
题目链接 Sort a linked list in O(n log n) time using constant space complexity.符合O(n log n)复杂度的算法有快速排序、桶排序、归并排序。其中快速排序需要交换元素不适用于列表;桶排序的空间复杂度为O(n);由于列表的特性,归并排序满足时间、空间复杂度。 唯一的难点就在于如何将列表二分。这里用到了快慢指针的...
2018-04-18 22:34:21 102
原创 python"自增"了解一下
许多语言里都有自增,像++i就是将i的值增加1。 写Python的时习惯性地用了自增运算,结果发现程序中的++i并没有增加1。怎么回事呢?python中的++i到底是什么意思?原来python中的数字类型是不可变数据。意思说的是数字类型数据在【内存】中是不会发生改变,当变量值发生改变时,会新申请一块内存赋值为新值,然后将变量指向新的内存地址。>>> a = 10&gt...
2018-04-14 10:15:24 29243 9
原创 ubuntu 日常操作
Disable Apport Error Reportingsudo vim /etc/default/apport enabled=1 修改为 enabled=0 参考链接except (IOError, OSError), e: SyntaxError: invalid syntax 这是python脚本是python2, 而解释器是python3的不匹配导致的问题。要么将默...
2018-04-12 22:10:18 400
原创 Leetcode 61. Rotate List
题目链接 Given a list, rotate the list to the right by k places, where k is non-negative. Example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NUL...
2018-04-11 23:50:34 89
原创 python中的json、pickle
json 提供了四个功能:dumps:将json数据转换为字符串 json.dumps(obj,skipkeys=False,separators=None,sort_keys=False)loads将字符串加载为json数据 json.loads(s)dump:将json数据序列化到文件 json.dump(obj, fp, sort_keys=False,)load:从文件加...
2018-04-07 16:10:52 321
原创 python字符串格式化—format
基本用法:>>>"my name is {} and I am {} years old".format("junex",18)>>>'my name is junex and I am 18 years old'“{}”相当于占位符,然后调用format()来赋值。如果既想用format(),又想输出“{}”怎么办?>>>
2018-04-07 12:54:59 248
原创 python日常
添加模块搜索路径动态添加目录import syssys.path.append("the directory of module")该方法只对包含以上语句的模块起作用。修改PYTHONPATH变量 windows下: 新建PYTHONPATH环境变量,然后将python模块所在的路径追加到该变量。 linux下:export PYTHONPATH=$PYTHONPATH...
2018-04-04 22:55:45 201
原创 方差(variance)
In probability theory and statistics, variance is the expectation of the squared deviation of a random variable from its mean.Informally, it measures how far a set of (random) numbers are spread ou...
2018-04-02 22:59:05 1359
原创 期望(Expectation)
In probability theory, the expected value of a random variable, intuitively, is the long-run average value of repetitions of the experiment it represents. 期望值像是随机试验在同样的机会下重复多次,所有那些可能状态平均的结果,便基本上...
2018-04-01 13:48:18 1329
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人