LeetCode
文章平均质量分 57
colourfulcloud
这个作者很懒,什么都没留下…
展开
-
LeetCode - Binary Tree Inorder Traversal
用一个stack实现循环方法: /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * };原创 2015-01-24 15:06:46 · 410 阅读 · 0 评论 -
Leetcode - Triangle
This problem is quite well-formed in my opinion. The triangle has a tree-like structure, which would lead people to think about traversal algorithms such as DFS. However, if you look closely, you woul转载 2015-01-16 16:47:25 · 419 阅读 · 0 评论 -
LeetCode - Single Number II
Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using转载 2015-01-16 16:04:35 · 441 阅读 · 0 评论 -
LeetCode - Unique Paths II
just use dp to find the answer , if there is a obstacle at (i,j), then dp[i][j] = 0. time is O(nm) , space is O(nm) . here is my code: class Solution { public: int uniquePathsWithObstacles(vector转载 2015-01-17 18:44:33 · 369 阅读 · 0 评论 -
LeetCode - Symmetric Tree
递归方法: /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class原创 2015-01-19 15:55:31 · 388 阅读 · 0 评论 -
LeetCode - Path Sum II
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ cla原创 2015-01-20 16:51:08 · 455 阅读 · 0 评论