L_Aster的专栏

相逢的人会再相逢

1. 两数之和

1. 两数之和 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { ...

2018-04-05 08:01:23

阅读数 41

评论数 0

310. Minimum Height Trees

310. Minimum Height Trees 从叶节点开始,依次删除他们,最后剩下1或者2个节点的就是树根,有点类似拓扑排序的感觉 参考:https://leetcode.com/problems/minimum-height-trees/discuss/76055/Share-some...

2018-04-03 10:03:14

阅读数 45

评论数 0

491. 递增子序列

491. 递增子序列 class Solution { public: vector<vector<int>> findSubsequences(vector<int&a...

2018-04-02 08:29:04

阅读数 154

评论数 0

513. 找树左下角的值

513. 找树左下角的值 class Solution { public: int findBottomLeftValue(TreeNode* root) { int maxdep=0,res=0; help(root,1,maxdep,res); ...

2018-04-02 07:43:08

阅读数 276

评论数 0

169. 求众数

169. 求众数 虽然用map记录也能过,但是明显其复杂度高,一个o(n)的解法(貌似是某年408算法题) class Solution { public: int majorityElement(vector<int>&...

2018-04-02 07:37:06

阅读数 1559

评论数 1

684. 冗余连接

684. 冗余连接 并查集 class Solution { public: vector<int> findRedundantConnection(vector<vector<int&am...

2018-04-01 18:05:36

阅读数 489

评论数 0

210. 课程表 II

210. 课程表 II class Solution { public: vector<int> findOrder(int numCourses, vector<pair<int, int&...

2018-04-01 17:42:56

阅读数 133

评论数 0

207. 课程表

207. 课程表 class Solution { public: bool canFinish(int numCourses, vector<pair<int, int>>&...

2018-04-01 17:02:37

阅读数 130

评论数 0

515. 在每个树行中找最大值

515. 在每个树行中找最大值 class Solution { public: vector<int> largestValues(TreeNode* root) { vector<int&amp...

2018-04-01 16:45:17

阅读数 193

评论数 0

199. 二叉树的右视图

199. 二叉树的右视图 class Solution { public: vector<int> rightSideView(TreeNode* root) { vector<int&gt...

2018-04-01 16:39:44

阅读数 288

评论数 0

200. 岛屿的个数

200. 岛屿的个数 class Solution { public: bool isvalid(int x,int y,int m,int n){ return x>=0&&x<...

2018-04-01 16:13:40

阅读数 341

评论数 0

111. 二叉树的最小深度

111. 二叉树的最小深度 class Solution { public: int minDepth(TreeNode* root) { if(!root) return 0; int mindepth=0x7fffffff; mDhel...

2018-04-01 15:49:29

阅读数 52

评论数 0

101. 对称二叉树

101. 对称二叉树 class Solution { public: bool isSymmetric(TreeNode* root) { if(root==NULL) return true; return sychelp(root-&am...

2018-04-01 15:36:00

阅读数 189

评论数 0

107. 二叉树的层次遍历 II

107. 二叉树的层次遍历 II class Solution { public: vector<vector<int>> levelOrderBottom(TreeNode* root) { ...

2018-04-01 15:17:09

阅读数 924

评论数 0

[LeetCode] 84. Largest Rectangle in Histogram

Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the his...

2018-03-24 13:41:16

阅读数 65

评论数 1

[LeetCode] 64. Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path....

2018-03-20 21:50:57

阅读数 67

评论数 0

[LeetCode] 746. Min Cost Climbing Stairs

On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps....

2018-03-04 11:18:07

阅读数 82

评论数 0

[LeetCode] 143. Reorder List

void reorderList(ListNode* head) { if(head==NULL||head->next==NULL) return; ListNode *l1=head,*l2=head->next; while(l2&&l2->n...

2017-09-11 11:33:01

阅读数 136

评论数 0

[LeetCode] 547. Friend Circles

int findCircleNum(vector<vector<int>>& M) { int n=M.size(); vector<int> parents(n,0); for(int i=0;i<n;++i) {...

2017-09-05 13:45:47

阅读数 178

评论数 0

[LeetCode] 22. Generate Parentheses

void pHelp(vector> &res,vector &rp,vector &nums,unordered_map &vis) { if(rp.size()==nums.size()) { res.push_back(rp); r...

2017-09-03 13:08:46

阅读数 128

评论数 0

提示
确定要删除当前文章?
取消 删除
关闭
关闭