• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 22 23 24 25 26 27 下一页
2013年3月19日
LeetCode: Combination Sum
摘要: 第一次没考虑到要加个系数cur, 因为必须从小到大排序,导致答案里有[1, 2]和[2, 1],加入cur后就acm了 1 class Solution { 2 public: 3 void dfs(vector candidates, int target, int sum, vector... 阅读全文
posted @ 2013-03-19 11:56 ying_vincent 阅读(139) 评论(0) 推荐(0)
LeetCode: Climbing Stairs
摘要: 一开始用dfs结果large超时,马上就想到dp了。。哎,下次先得去想dp啊。。 1 class Solution { 2 public: 3 int climbStairs(int n) { 4 // Start typing your C/C++ solution bel... 阅读全文
posted @ 2013-03-19 11:42 ying_vincent 阅读(139) 评论(0) 推荐(0)
LeetCode: Binary Tree Zigzag Level Order Traversal
摘要: 出错了一次,改了一次,小失误没用弄好zigzag的排序。题目还是简单的 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * T... 阅读全文
posted @ 2013-03-19 11:34 ying_vincent 阅读(191) 评论(0) 推荐(0)
LeetCode: Binary Tree Maximum Path Sum
摘要: 这题比较难,没理顺关系,做了很多次还只是过了small judge,于是去看网上答案,然后再改了改,关键在于local_max和globe_max,globe_max要随时改得,而maxsum函数只是返回最大路径 1 /** 2 * Definition for binary tree 3 * ... 阅读全文
posted @ 2013-03-19 11:13 ying_vincent 阅读(189) 评论(0) 推荐(0)
2013年3月18日
LeetCode: Binary Tree Level Order Traversal II
摘要: 跟1基本一样,就是用个stack就解决了,算一次过吧 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *... 阅读全文
posted @ 2013-03-18 10:24 ying_vincent 阅读(184) 评论(0) 推荐(0)
LeetCode: Binary Tree Level Order Traversal
摘要: C++ 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * ... 阅读全文
posted @ 2013-03-18 09:54 ying_vincent 阅读(129) 评论(0) 推荐(0)
LeetCode: Binary Tree Inorder Traversal
摘要: 一次过 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNod... 阅读全文
posted @ 2013-03-18 09:40 ying_vincent 阅读(166) 评论(0) 推荐(0)
LeetCode: Best Time to Buy and Sell Stock III
摘要: 思路对的,但是没弄好code,改了挺多,最后还是runtime exceed了,看了网上答案再把自己的code改了改 1 class Solution { 2 public: 3 int maxProfit(vector &prices) { 4 // Start typin... 阅读全文
posted @ 2013-03-18 09:12 ying_vincent 阅读(160) 评论(0) 推荐(0)
2013年3月17日
LeetCode: Best Time to Buy and Sell Stock II
摘要: 少数次修改吧,忘了加最后一个递增曲线了 1 class Solution { 2 public: 3 int maxProfit(vector &prices) { 4 // Start typing your C/C++ solution below 5 /... 阅读全文
posted @ 2013-03-17 19:01 ying_vincent 阅读(139) 评论(0) 推荐(0)
LeetCode: Best Time to Buy and Sell Stock
摘要: 一次过 1 class Solution { 2 public: 3 int maxProfit(vector &prices) { 4 // Start typing your C/C++ solution below 5 // DO NOT write i... 阅读全文
posted @ 2013-03-17 18:53 ying_vincent 阅读(130) 评论(0) 推荐(0)
上一页 1 ··· 22 23 24 25 26 27 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3