自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

wlxsq的专栏

学着玩,玩着学,一步一步走着来。

  • 博客(35)
  • 收藏
  • 关注

原创 【DP】递推【91. Decode Ways】

题目链接:https://leetcode.com/problems/decode-ways/#/descriptionclass Solution {public: int numDecodings(string s) { int len=s.size(); if(len==0||s[0]=='0') return 0; vector

2017-07-23 16:34:59 281

原创 【DP】最长回文字串【516. Longest Palindromic Subsequence】

题目链接:https://leetcode.com/problems/longest-palindromic-subsequence/#/descriptionclass Solution {public: int longestPalindromeSubseq(string s) { int len=s.size(); // 创建一个二维数组,指定

2017-07-22 10:38:06 213

原创 DP入门题目

基本思想:将待求解的问题分解成若干个相互联系的子问题,先求解子问题,然后从这些子问题的解得到原问题的解;对于重复出现的子问题,只在第一次遇到的时候对它进行求解,并把答案保存起来,让以后再次遇到时直接引用答案,不必重新求解。 课堂题目:1、斐波那契数列题目描述:http://acm.hdu.edu.cn/showproblem.php?pid=2041           有一楼

2017-07-19 13:36:23 423

原创 题目列表

这几天的题目列表1、层次遍历https://leetcode.com/problems/average-of-levels-in-binary-tree/#/description2、合并二叉树 https://leetcode.com/problems/merge-two-binary-trees/#/description3、计算左叶的和 https://leetcode.com

2017-07-17 16:34:24 269

原创 【链表】链表的逆序【Add to List 206. Reverse Linked List】

题目链接:https://leetcode.com/problems/reverse-linked-list/#/description/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val

2017-07-17 16:28:48 274

原创 【二叉树】有序数组建平衡二叉树【108. Convert Sorted Array to Binary Search Tree】

题目链接:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; *

2017-07-16 10:14:42 289

原创 【二叉树】二分查找树有序遍历【538. Convert BST to Greater Tree】

题目链接:https://leetcode.com/problems/convert-bst-to-greater-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *rig

2017-07-16 10:14:10 248

原创 【二叉树】后序遍历【Add to List 145. Binary Tree Postorder Traversal】

题目链接:https://leetcode.com/problems/binary-tree-postorder-traversal/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode

2017-07-16 10:13:27 216

原创 【DP】博弈【486. Predict the Winner】

题目链接:https://leetcode.com/problems/predict-the-winner/#/descriptionclass Solution {public: bool PredictTheWinner(vector& nums) { int len=nums.size(); int sum=0; for(int

2017-07-16 10:12:53 275

原创 【DP】添加n个数+-,统计和为S的方案数【494. Target Sum】

题目链接:https://leetcode.com/problems/target-sum/#/descriptionclass Solution {public: int findTargetSumWays(vector& nums, int S) { int dp[2001]={0}; dp[1000+nums[0]]=1; dp[

2017-07-16 10:12:29 444

原创 【二叉树】指定深度添加一层节点【623. Add One Row to Tree】

题目链接:https://leetcode.com/problems/add-one-row-to-tree/#/solutions/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; *

2017-07-15 12:04:14 399

原创 【DP】简单【121. Best Time to Buy and Sell Stock】【303. Range Sum Query - Immutable】

题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock/#/descriptionclass Solution {public: int maxProfit(vector& prices) { int len=prices.size(); if(len==0) return

2017-07-15 12:03:09 260

原创 【二叉树】二叉树反转【Add to List 226. Invert Binary Tree】

题目链接:https://leetcode.com/problems/invert-binary-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; *

2017-07-15 12:02:44 220

原创 【二叉树】BST第K小值【230. Kth Smallest Element in a BST】

题目链接:https://leetcode.com/problems/kth-smallest-element-in-a-bst/#/discuss/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right

2017-07-15 12:02:13 273

原创 【数位DP】【357. Count Numbers with Unique Digits】

题目链接:https://leetcode.com/problems/count-numbers-with-unique-digits/#/descriptionclass Solution {public: int bit[15]={0}; // 保存最大值,999999... int dp[15]={0}; // 符合要求的方案数 int a[1

2017-07-15 12:01:07 262

原创 【二叉树】二分查找树,节点删除【Add to List 450. Delete Node in a BST】

题目链接:https://leetcode.com/problems/delete-node-in-a-bst/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; *

2017-07-14 09:53:44 303

原创 【二叉树】字符串打印树结构/路径【606. Construct String from Binary Tree】【257. Binary Tree Paths】【102. Binary Tree Le

题目链接:https://leetcode.com/problems/construct-string-from-binary-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNod

2017-07-14 09:48:02 259

原创 【二叉树】树的序列化和反序列化【449. Serialize and Deserialize BST】

题目链接:https://leetcode.com/problems/serialize-and-deserialize-bst/#/description树的序列化与反序列化(看完有惊喜0.0)序列化参照https://leetcode.com/problems/construct-string-from-binary-tree/#/description将树[2,1,3]转化成2(

2017-07-14 09:40:00 669

原创 【二叉树】BST中序遍历【99. Recover Binary Search Tree】

题目链接:https://leetcode.com/problems/recover-binary-search-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *righ

2017-07-14 09:39:39 420

原创 【二叉树】最大路径和【124. Binary Tree Maximum Path Sum】

题目链接:https://leetcode.com/problems/binary-tree-maximum-path-sum/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *ri

2017-07-14 09:39:15 533

原创 【链表】节点的插入删除【25. Reverse Nodes in k-Group】

题目链接:https://leetcode.com/problems/reverse-nodes-in-k-group/#/description/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x)

2017-07-13 09:02:37 328

原创 【二叉树】树的直径【543. Diameter of Binary Tree】

题目链接:https://leetcode.com/problems/diameter-of-binary-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;

2017-07-13 09:01:43 480

原创 【二叉树】计算二叉树深度【104. Maximum Depth of Binary Tree】【111. Minimum Depth of Binary Tree】

题目链接:https://leetcode.com/problems/maximum-depth-of-binary-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *ri

2017-07-13 09:00:33 363

原创 【二叉树】二分查找树,中序遍历,统计出现次数最多的节点【Add to List 501. Find Mode in Binary Search Tree】

题目链接:https://leetcode.com/problems/find-mode-in-binary-search-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode

2017-07-13 09:00:02 451

原创 【二叉树】最近公共祖先【235. Lowest Common Ancestor of a Binary Search Tree】

题目链接:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left;

2017-07-13 08:58:11 301

原创 【二叉树】DFS计算路径和,保存路径【113. Path Sum II】【112. Path Sum】

题目链接:https://leetcode.com/problems/path-sum-ii/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeN

2017-07-12 10:43:27 925

原创 【二叉树】DFS统计节点和出现的个数

题目链接:https://leetcode.com/problems/path-sum-iii/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * Tree

2017-07-12 09:10:31 928

原创 【二叉树】判断二叉树是否对称

题目链接:https://leetcode.com/problems/symmetric-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * Tr

2017-07-12 08:41:42 638

原创 【二叉树】一棵树的子树是一颗树

题目链接:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * };

2017-07-12 08:40:47 420

原创 【二叉树】判断二叉树是否为平衡二叉树

题目链接:https://leetcode.com/problems/balanced-binary-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; *

2017-07-12 08:40:29 377

原创 【二叉树】判断两棵树是否相同

题目链接:https://leetcode.com/problems/same-tree/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNod

2017-07-11 20:22:45 833

原创 【二叉树】计算儿子节点和

题目链接:https://leetcode.com/problems/binary-tree-tilt/#/description注意:titl的定义是儿子节点的和的绝对值之和/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; *

2017-07-11 19:39:47 799

原创 【二叉树】计算左叶的和

题目链接:https://leetcode.com/problems/sum-of-left-leaves/#/description注意:叶子节点:一棵树当中没有子结点(即度为0)的结点,称为叶子结点,简称“叶子”。 叶子是指度为0的结点,又称为终端结点。/** * Definition for a binary tree node. * struct TreeNode { *

2017-07-11 18:10:10 318

原创 【二叉树】合并二叉树

题目链接:https://leetcode.com/problems/merge-two-binary-trees/#/description/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right;

2017-07-11 17:47:22 2076 1

原创 【二叉树】层次遍历

题目链接:https://leetcode.com/problems/average-of-levels-in-binary-tree//** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; *

2017-07-11 17:13:48 216

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

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