• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 21 22 23 24 25 26 27 下一页
2013年3月20日
LeetCode: Distinct Subsequences
摘要: 一开始dfs没过large, 网上看了别人的dp,哎,这题比较难。。 1 class Solution { 2 public: 3 int numDistinct(string S, string T) { 4 // Start typing your C/C++ solut... 阅读全文
posted @ 2013-03-20 17:10 ying_vincent 阅读(196) 评论(0) 推荐(0)
LeetCode: Decode Ways
摘要: 一开始dfs runtime exceed, 后来用dp想复杂了就看网上答案 1 class Solution { 2 public: 3 int numDecodings(string s) { 4 // Start typing your C/C++ solution b... 阅读全文
posted @ 2013-03-20 02:21 ying_vincent 阅读(151) 评论(0) 推荐(0)
2013年3月19日
LeetCode: Count and Say
摘要: 题意理解有误,看了网上答案才弄出来 1 class Solution { 2 public: 3 string countAndSay(int n) { 4 // Start typing your C/C++ solution below 5 // DO N... 阅读全文
posted @ 2013-03-19 19:34 ying_vincent 阅读(157) 评论(0) 推荐(0)
LeetCode: Convert Sorted List to Binary Search Tree
摘要: 第一次想用懒汉方法把list弄成vector再照前一题的方法,结果被判Memory exceed了。。然后只好再写次 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *... 阅读全文
posted @ 2013-03-19 16:44 ying_vincent 阅读(152) 评论(0) 推荐(0)
LeetCode: Convert Sorted Array to Binary Search Tree
摘要: 一次过 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNod... 阅读全文
posted @ 2013-03-19 16:05 ying_vincent 阅读(159) 评论(0) 推荐(0)
LeetCode: Container With Most Water
摘要: 第一次用了个O(n^2)的算法large没过,就仔细想了想,少数次过吧 1 class Solution { 2 public: 3 int maxArea(vector &height) { 4 // Start typing your C/C++ solution bel... 阅读全文
posted @ 2013-03-19 15:37 ying_vincent 阅读(144) 评论(0) 推荐(0)
LeetCode: Construct Binary Tree from Preorder and Inorder Traversa
摘要: 跟inorder and postorder基本一样,一次过吧 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeN... 阅读全文
posted @ 2013-03-19 15:21 ying_vincent 阅读(172) 评论(0) 推荐(0)
LeetCode: Construct Binary Tree from Inorder and Postorder Traversal
摘要: 第一次只用4个系数写dfs怎么写都不对,后来看了网上的答案发现写右子树的时候开始点不一样的。。。所以要用5个系数 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeN... 阅读全文
posted @ 2013-03-19 15:02 ying_vincent 阅读(178) 评论(0) 推荐(0)
LeetCode: Combinations
摘要: 初始系数没弄好,改了一次 加一个iterative的方法 C# 1 public class Solution { 2 public List<List<int>> Combine(int n, int k) { 3 List<List<int>> ans = new List<List<int>> 阅读全文
posted @ 2013-03-19 13:50 ying_vincent 阅读(127) 评论(0) 推荐(0)
LeetCode: Combination Sum II
摘要: 改了挺多次,不过最后还是被我搞出来了^^, 用了map的技巧勉强过了large。 1 class Solution { 2 public: 3 void dfs(vector num, int target, int sum, vector &save, map, int> &reti, i... 阅读全文
posted @ 2013-03-19 13:39 ying_vincent 阅读(181) 评论(0) 推荐(0)
上一页 1 ··· 21 22 23 24 25 26 27 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3