摘要: http://oj.leetcode.com/problems/same-tree/ 1 class Solution { 2 public: 3 bool isSameTree(TreeNode *p, TreeNode *q) { 4 // IMPORTANT: Please reset any member data you declared, as 5 // the same Solution instance will be reused for each test case. 6 if (p == NULL && q == N... 阅读全文
posted @ 2013-11-06 01:21 NextLife 阅读(167) 评论(0) 推荐(0)
摘要: http://oj.leetcode.com/problems/two-sum/这道题如果第二层循环用二分, 那么时间复杂度是O(nlogn), 而我的做法是哈希表unordered_map, 幸好LeetCode支持C++11. 1 class Solution { 2 public: 3 vector twoSum(vector &numbers, int target) { 4 // IMPORTANT: Please reset any member data you declared, as 5 // the same Solution ins... 阅读全文
posted @ 2013-11-06 00:01 NextLife 阅读(192) 评论(0) 推荐(0)