上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: Problem Description:http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/Basic idea: from code below, it seems super easy. But intuitively, we may use one more variable "tmp_max_profit" to record every times we get the max profit. 1 class Solution { 2 public: 3 int maxProfit( 阅读全文
posted @ 2013-10-19 14:57 假日笛声 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Problem Description:http://oj.leetcode.com/problems/word-search/Basic idea: recursively go forward, use char '#' to mark the char visited, so no extra memory is need, don't forget to recover the previous char if the program cannot go forward. 1 class Solution { 2 public: 3 bool existSub( 阅读全文
posted @ 2013-10-18 14:48 假日笛声 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Problem Description:http://oj.leetcode.com/problems/same-tree/ 1 class Solution { 2 public: 3 bool isSameTree(TreeNode *p, TreeNode *q) { 4 // Note: The Solution object is instantiated only once and is reused by each test case. 5 if(p == NULL && q == NULL) 6 return tr... 阅读全文
posted @ 2013-10-18 06:14 假日笛声 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Problem Description:http://oj.leetcode.com/problems/reverse-nodes-in-k-group/Basic Idea: Do it like reverse a linked list with a counter started by k.... 阅读全文
posted @ 2013-10-17 14:11 假日笛声 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Problem Description:http://oj.leetcode.com/problems/text-justification/Note: Just be careful about boundary when implementing it. 1 class Solution { 2 public: 3 string genNormalLine(vector &words, int L, int start, int end){ 4 int word_count = end - start + 1; 5 string line; 6 ... 阅读全文
posted @ 2013-10-16 11:34 假日笛声 阅读(556) 评论(0) 推荐(0) 编辑
摘要: Problem Description:http://oj.leetcode.com/problems/path-sum/Pretty easy. 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11... 阅读全文
posted @ 2013-10-14 07:51 假日笛声 阅读(195) 评论(0) 推荐(0) 编辑
摘要: Problem Descriptionhttp://oj.leetcode.com/problems/multiply-strings/Basic idea is to multiply two nums like we do caculation on paper, one by one digital multiplication, then add the temporary results together to get the final one. Be careful about the last carry digital. 1 class Solution { 2 public 阅读全文
posted @ 2013-10-12 15:19 假日笛声 阅读(451) 评论(0) 推荐(0) 编辑
摘要: Problem Descriptionhttp://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/Basic idea is to get every nodes in the current level by iterating nodes of the previous level, then to iterate all nodes in current level to connect them with pointer "next". 1 /** 2 * Defini 阅读全文
posted @ 2013-10-11 15:03 假日笛声 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 今天帮助David 调程序。他在做Windows下程序分析,使用一个数组存放目标程序heap中所有的数据结构(地址和Size),然后扫描该程序全局数据段所有内容,如果某个指针指向的值落在heap中某个数据结构地址范围内,就建立从全局数据段到该数据结构的路径。David给我演示时, 说运行Toy program 没问题,但运行一个比较大的真实程序时,就会出现性能问题,果然,我们等了二十多分钟,还是没有算完。于是我检查了他的代码,告诉他问题可能出在检查指针是否指向有效数据结构时,他是用的线性查找方法。我说,考虑到他的数组已经排序, 使用二分查找法,会快很多,因为算法复杂度从O(N)降到了O(log 阅读全文
posted @ 2013-05-24 15:02 假日笛声 阅读(636) 评论(0) 推荐(0) 编辑
摘要: 为了分析计算机操作系统的运行状态和内容,或者进行内存取证,我们经常需要取得系统的物理内存,并把它保存在一个文件中,用于以后的分析和处理。那么如何取得系统的内存呢?有几种方法,我一一道来。利用虚拟机保存物理内存:如果目标系统在虚拟机中,无论系统类型是什么(Windows, Linux, *BSD, Minix, Solaris),我们都可以借助虚拟机来取得Guest OS的内存。具体来说,如果我们使用的虚拟机是VMware Workstation, 我们可以使用take a snapshot功能,每次Take a snapshot, 我们就会得到一堆文件,其中*.vmem就是Guest OS的物 阅读全文
posted @ 2013-05-23 12:34 假日笛声 阅读(881) 评论(0) 推荐(1) 编辑
上一页 1 ··· 3 4 5 6 7 8 下一页