
leedcode
chde2Wang
滴水穿石
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leedcode1-求树的最小高度
#include<iostream> #include<algorithm> #include<queue> using namespace std; //5种情况:空树;没有子树;只有左/右子树;有俩子树; struct BinaryNode { BinaryNode *left; BinaryNode *right; int data; }; s...原创 2019-06-04 17:30:11 · 343 阅读 · 0 评论 -
原 Leedcode11-word-break-ii
Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, givens="catsan...原创 2019-07-28 21:38:20 · 116 阅读 · 0 评论 -
Leedcode7-binary-tree-postorder-traversal
#include<iostream> #include<vector> #include<stack> using namespace std; // Definition for binary tree 先序遍历 根左右 struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeN...原创 2019-07-22 18:20:27 · 138 阅读 · 0 评论 -
Leedcode6-binary-tree-preorder-traversal
#include<iostream> #include<vector> #include<stack> using namespace std; // Definition for binary tree 先序遍历 根左右 struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeN...原创 2019-07-22 18:13:56 · 108 阅读 · 0 评论 -
Leedcode12-word-break-i
/*Given a string s and a dictionary of words dict, determine if s can be segmented into a space - separated sequence of one or more dictionary words. For example, given s = "leetcode", dict = ["lee...原创 2019-07-30 21:42:49 · 124 阅读 · 0 评论 -
Leedcode9-linked-list-cycle-i
判断链表是不是循环链表 #include<iostream> #include<vector> using namespace std; /* Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?*/ s...原创 2019-07-25 16:13:43 · 128 阅读 · 0 评论 -
Leedcode8-reorder-list
#include<iostream> #include<vector> using namespace std; //Definition for singly-linked list. /*Given a singly linked list L : L 0→L 1→…→L n - 1→L n, reorder it to : L 0→L n →L 1→L n - 1→...原创 2019-07-25 16:11:58 · 113 阅读 · 0 评论 -
Leedcode3- Max Points on a Line 共线点个数
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line. Input: [[1,1],[2,2],[3,3]] Output: 3 Input: [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] Output: 4 ...原创 2019-07-17 16:26:37 · 180 阅读 · 0 评论 -
Leedcode2-后缀表达式结果
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another expression. Some examples: ["2", "1", "+", "3", ...原创 2019-07-17 16:22:18 · 124 阅读 · 0 评论 -
Leedcode5-Sort a linked list using insertion sort.
#include<iostream> using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; #if 0 class Solution { public: ListNode *insertionSortList(...原创 2019-07-18 16:09:00 · 128 阅读 · 0 评论 -
Leedcode4-sort listnode 归并排序
#include<iostream> using namespace std; //Sort a linked list in O(n log n) time using constant space complexity. //Definition for singly-linked list. //归并排序 #if 0 struct ListNode { int v...原创 2019-07-18 15:16:52 · 231 阅读 · 0 评论