- 博客(24)
- 收藏
- 关注
转载 【笔记】virtualbox+arch+kde5安装流水账
正常安装就是RTFD就行了,不行辅助这几个链接也行: 我先把整个脚本[1]放这里:loadkeys uspartedmkfs.ext4 /dev/sda1mkfs.ext4 /dev/sda3mkswap /dev/sda2 && swapon /dev/sda2mount /dev/sda3 /mntcd /mntmkdir bootm...
2016-04-28 00:58:00 174
转载 有关C++模板inline的高性能在lambda与function的体现
前两天在群里跟人讨论到写库时对于lambda和function的取舍,跑了写测试查了些资料后基本得出结论:如果没有自由变量的情况下,一般不要用function。如果有自由变量的话,C++中的lambda就是一个匿名类的实例,而如果没有的话,就是一个单纯的函数指针。为什么说尽量不要用function呢?我们来看一下下面的代码:void lambdatest(vector&l...
2015-03-25 20:35:00 641
转载 [leetcode] 21. Implement strStr()
这个题目是典型的KMP算法,当然也可以试试BM,当然有关KMP和BM的介绍阮一峰曾经写过比较好的科普,然后july也有讲解,不过那个太长了。 先放题目吧: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of...
2014-12-02 15:43:00 92
转载 [leetcode] 20. Valid Sudoku
这道题目被放在的简单的类别里是有原因的,题目如下: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '....
2014-12-02 15:19:00 151
转载 [leetcode] 19. Count and Say
这个还是一开始没读懂题目,题目如下:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21...
2014-11-26 00:04:00 85
转载 [leetcode] 18. Length of Last Word
这个题目很简单,给一个字符串,然后返回最后一个单词的长度就行。题目如下: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does n...
2014-11-25 23:55:00 74
转载 [leetcode] 17. Merge Two Sorted Lists
这个非常简单的题目,题目如下: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 就是算导里面的第一个算法讲解,但是我的C++水平实在太渣,所以对于链表的...
2014-11-24 23:30:00 75
转载 [leetcode] 16. Add Binary
这个题目相对有点奇怪,题目如下: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 可能是我思路的问题吧,我之前是在考虑先将string转成int或者double,然后将二进制转为十进制进行计算,最后再将这个十进...
2014-11-24 23:26:00 89
转载 [leetcode] 15. Plus One
这道题其实让我意识到了我的英文水平还有待加强。。。。题目如下:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the h...
2014-11-23 22:59:00 55
转载 [leetcode] 14. Climbing Stairs
这道题leetcode上面写着是DP问题,问题是我一开始写了个简单的递归结果直接超时,所以没办法只好拿迭代来做了。题目如下: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many disti...
2014-11-23 22:50:00 67
转载 [leetcode] 13. Remove Duplicates from Sorted List
这个题目其实不难的,主要是我C++的水平太差了,链表那里绊了好久,但是又不像用python,所以还是强行上了。 题目如下: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return...
2014-11-22 16:37:00 65
转载 [leetcode] 12. Merge Sorted Array
这道题的无聊之处在于题目其实给了一些很奇怪的测试用例。比如他会给一些空的数组来,但是这个是不科学的,因为在C++中不允许定义一个空的列表,我们用的又不是那种糙又快的python,所以在这里我遇到了一些问题,后来还是解决了。这道题题目如下:Given two sorted integer arrays A and B, merge B into A as one sorted ar...
2014-11-20 22:56:00 76
转载 [编译,报错以及其他] 有关C/C++中int不能用-2147483648当最小值的问题
这个取决于今早看耗子叔的微博: 这里说到了int的取值范围的问题,int的取值是-2147483648 ~ 2147483647,但是如果直接在编译器(VS2013)中使用-2147483648会报错: error C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型 编译器(VS2013)在看到-2147483648时,会先做一个判断,就是先做一个2147483648 &...
2014-11-18 16:38:00 792
转载 [leetcode] 11. Same Tree
因为我刷题是难度不是按发布日期,所以就有可能遇到这种情况,比如这个。。。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 and t...
2014-11-18 13:40:00 75
转载 [leetcode] 10. Symmetric Tree
这次我觉得我的智商太低,想了很久才写出来。题目是让求镜像二叉树判断,题目如下:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 /...
2014-11-18 12:57:00 78
转载 [leetcode] 9. Binary Tree Level Order Traversal
跟第七题一样,把最后的输出顺序换一下就行。。。Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7},...
2014-11-15 20:59:00 67
转载 [leetcode] 8. Maximum Depth of Binary Tree
可能是因为我是按难度顺序刷的原因,这个其实在之前的几道题里面已经写过了。题目如下: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest lea...
2014-11-15 20:53:00 82
转载 [leetcode] 7. Binary Tree Level Order Traversal II
这次相对来讲复杂点,题目如下: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree ...
2014-11-15 00:44:00 71
转载 [leetcode] 6. Balanced Binary Tree
这个题目纠结了一会儿,终于从二叉树转化到AVL了。题目如下:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the t...
2014-11-13 11:18:00 63
转载 [leetcode] 5. Minimum Depth of Binary Tree
二叉树基本功练习题,题目如下:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.就是找最短的那条从根到叶...
2014-11-12 19:43:00 122
转载 [leetcode] 4. Path Sum
终于到了二叉树。题目如下:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below ...
2014-11-11 23:45:00 75
转载 [leetcode] 3. Pascal's Triangle
第三道还是帕斯卡三角,这个是要求正常输出,题目如下:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6...
2014-11-11 09:28:00 66
转载 [leetcode] 2. Pascal's Triangle II
我是按难度往下刷的,第二道是帕斯卡三角形二。简单易懂,题目如下:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to use onl...
2014-11-11 00:34:00 82
转载 [leetcode] 1. Valid Palindrome
leetcode的第一题,回文数判断。原题如下:For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome.Note: Have you consider that the string might be empty? This ...
2014-11-09 19:06:00 96
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人