qingcheng奕  
上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页

2014年7月27日

摘要: https://oj.leetcode.com/problems/recover-binary-search-tree/一棵二叉搜索树,二叉搜索树的特征是,中根遍历的话,得到的序列是递增的题目中,有两个节点弄混了,让恢复这个二叉搜索树class Solution {public: TreeNo... 阅读全文
posted @ 2014-07-27 15:34 qingcheng奕 阅读(119) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/powx-n/二分法class Solution {public: double pow(double x, int n) { double ans = 1; if(n == 0) ... 阅读全文
posted @ 2014-07-27 13:39 qingcheng奕 阅读(121) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/接上一题目,输入的树不是perfect的。在这里深搜就不好使了。因为,在你往下深搜的时候,可能上一行的next还没处理到那里,所以会丢失信息... 阅读全文
posted @ 2014-07-27 12:44 qingcheng奕 阅读(128) 评论(0) 推荐(0) 编辑

2014年7月26日

摘要: https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/二叉树遍历的变种:树的节点多了个next指针。首先想到肯定和树的遍历有关:先根、中根、后根都不可以。。。观察找规律,如果当前节点是它根的 left... 阅读全文
posted @ 2014-07-26 21:17 qingcheng奕 阅读(110) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/search-a-2d-matrix/具有数据递增性质的一个二维数组,对它进行二分搜索。首先搜索target所在的行,再找列。class Solution {public: bool searchMatrix(vector > ... 阅读全文
posted @ 2014-07-26 20:54 qingcheng奕 阅读(152) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/max-points-on-a-line/给n多个二维平面上的点,求其中在同一条直线上点的最大数细节题,也挺考脑力的class Solution {public: int maxPoints(vector &points) { ... 阅读全文
posted @ 2014-07-26 20:20 qingcheng奕 阅读(135) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/给一个string,找出其中不含有重复元素的最长子串的长度。class Solution {public: int lengthOfL... 阅读全文
posted @ 2014-07-26 18:35 qingcheng奕 阅读(125) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/longest-palindromic-substring/给一个string,求它的最长回文子串。定义一个二维数组bool isPal[1000][1000];记录从 i 到 j 是否为回文的。首先初始化 [i][i] = true... 阅读全文
posted @ 2014-07-26 16:39 qingcheng奕 阅读(83) 评论(0) 推荐(0) 编辑

2014年7月23日

摘要: https://oj.leetcode.com/problems/longest-common-prefix/在多个string的集合中,找出所有string的最长公共前缀。从头开始 index 如果 所有string的 index位都相等,则index ++string是一个类,如果是 空stri... 阅读全文
posted @ 2014-07-23 22:28 qingcheng奕 阅读(91) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/length-of-last-word/对一个字符串遍历,求最后一个单词的长度,如果有 ‘ ’,则切开了。字符串的最后一个字符为 '\0'NULL和“”是有区别的:NULL是 0x00000 , ""是长度为1的串,里面只有结尾元素,... 阅读全文
posted @ 2014-07-23 21:40 qingcheng奕 阅读(95) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 23 下一页