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

2014年8月16日

摘要: https://oj.leetcode.com/problems/merge-k-sorted-lists/这道题主要是考虑测试数据的特点吧。刚开始的时候想,每次找出头结点中最小的两个,然后取最小的一个,一直取到它的值 > 倒数第二小的,之后重复这个过程。适合的数据特点为: 1 2 3 5 6 7 ... 阅读全文
posted @ 2014-08-16 11:19 qingcheng奕 阅读(173) 评论(0) 推荐(0)

2014年8月14日

摘要: https://oj.leetcode.com/problems/text-justification/细节题class Solution {public: vector fullJustify(vector &words, int L) { vector ans; ... 阅读全文
posted @ 2014-08-14 20:31 qingcheng奕 阅读(119) 评论(0) 推荐(0)
 
摘要: https://oj.leetcode.com/problems/interleaving-string/刚开始用递归做,但是超时了class Solution {public: bool flag; bool isInterleave(string s1, string s2,... 阅读全文
posted @ 2014-08-14 07:58 qingcheng奕 阅读(138) 评论(0) 推荐(0)

2014年8月6日

摘要: 二叉树的遍历,先根遍历,不适用递归,存储空间为 O(1)转自:http://chuansongme.com/n/100461MorrisInOrder(): while 没有结束 如果当前节点没有左后代 // 则它就是最左了 所以 读取该点 访问该节点 转向右节点 否则 ... 阅读全文
posted @ 2014-08-06 23:20 qingcheng奕 阅读(167) 评论(0) 推荐(0)

2014年8月5日

摘要: https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/树的层序遍历使用两个 stack 或者 vector 分别表示 当前层和下一层/** * Definition for binary tree * st... 阅读全文
posted @ 2014-08-05 23:08 qingcheng奕 阅读(150) 评论(0) 推荐(0)
 
摘要: https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/使用递归,深搜,使用 map 保存已经处理过的结果class Solution {public: unordered_map > memory; ... 阅读全文
posted @ 2014-08-05 21:06 qingcheng奕 阅读(209) 评论(0) 推荐(0)

2014年8月3日

摘要: 转自:http://blog.csdn.net/hairetz/article/details/4141043一、预备知识—程序的内存分配 一个由C/C++编译的程序占用的内存分为以下几个部分 1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其 操作方式类似于数据... 阅读全文
posted @ 2014-08-03 22:26 qingcheng奕 阅读(176) 评论(0) 推荐(0)

2014年8月2日

摘要: https://oj.leetcode.com/problems/valid-sudoku/给出数独的一部分来,验证给出的这一部分是否为 valid行上无重复的,且是从 ‘1’ 到‘9’列上无重复的,且是从 ‘1’ 到‘9’小的3*3无重复的,且是从 ‘1’ 到‘9’class Solution {... 阅读全文
posted @ 2014-08-02 15:44 qingcheng奕 阅读(101) 评论(0) 推荐(0)
 
摘要: https://oj.leetcode.com/problems/word-break-ii/class Solution {public: unordered_set dict; string s; unordered_map > memory; //用来记录一个string可... 阅读全文
posted @ 2014-08-02 15:12 qingcheng奕 阅读(130) 评论(0) 推荐(0)

2014年8月1日

摘要: https://oj.leetcode.com/problems/surrounded-regions/棋盘类的题目。找出所有没有被 X 包围的 O使用深搜,但是太深了,run time error可以自己写个栈,模拟深搜,取数据存入,弹出的后来参考了九章struct point{ i... 阅读全文
posted @ 2014-08-01 21:23 qingcheng奕 阅读(121) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 23 下一页