• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 27 下一页
2013年4月21日
LeetCode: Sum Root to Leaf Numbers
摘要: 少数次过 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNo... 阅读全文
posted @ 2013-04-21 17:38 ying_vincent 阅读(132) 评论(0) 推荐(0)
LeetCode: Sudoku Solver
摘要: 看了网上答案,发现一个很有趣的问题,check函数里形参board是传值时(即&board)速度很快,能过large,去掉这个&后就过不了large了,是不是因为没有传值的话每次需要复制这样耗了时间了呢 1 class Solution { 2 public: 3 bool check(in... 阅读全文
posted @ 2013-04-21 17:27 ying_vincent 阅读(299) 评论(0) 推荐(0)
LeetCode: Substring with Concatenation of All Words
摘要: 自己想的大体思路还是对的,不过可以改进的很多,最后网上找了个勉勉强强过large的答案,用map实在太容易超时了。。 1 class Solution { 2 public: 3 vector findSubstring(string S, vector &L) { 4 //... 阅读全文
posted @ 2013-04-21 14:55 ying_vincent 阅读(222) 评论(0) 推荐(0)
LeetCode: Subsets II
摘要: 这题自己没想出来看了网上答案,才知道只要在上一题的基础上改用set而不用vector就可以了,set和vector的区别就在于set里没有重复元素,只要用set.insert(*), 会自动识别是否重复。set好牛逼。。 1 class Solution { 2 public: 3 void dfs(int cur, int n, set<vector<int>> &T, vector<int> &tmp, vector<int> S) { 4 if (cur == n) { 5 T.insert(tmp); 6 retu... 阅读全文
posted @ 2013-04-21 12:51 ying_vincent 阅读(165) 评论(0) 推荐(0)
LeetCode: Subsets
摘要: 脑子有点混,少数次过 1 class Solution { 2 public: 3 void dfs(int cur, int n, vector> &ret, vector &tmp, vector S) { 4 if (cur == n) { 5 ... 阅读全文
posted @ 2013-04-21 11:26 ying_vincent 阅读(139) 评论(0) 推荐(0)
LeetCode: String to Integer (atoi)
摘要: 这种题就是考你考虑了多少些情况,第一次没有考虑到的情况有:+-号,超出int范围,多数次过 1 class Solution { 2 public: 3 int atoi(const char *str) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 bool showed = false; 7 int s = 0; 8 bool negtive = false; 9 ... 阅读全文
posted @ 2013-04-21 10:43 ying_vincent 阅读(158) 评论(0) 推荐(0)
LeetCode: Sqrt(x)
摘要: 一点小失误,基本一次过吧 1 class Solution { 2 public: 3 int sqrt(int x) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int ma... 阅读全文
posted @ 2013-04-21 09:43 ying_vincent 阅读(141) 评论(0) 推荐(0)
LeetCode: Spiral Matrix II
摘要: 一次过 1 class Solution { 2 public: 3 bool out(int x, int y, int n) { 4 if (x >= n || x = n || y > &ret, int dir[4][2], int dep, int n, int d... 阅读全文
posted @ 2013-04-21 09:32 ying_vincent 阅读(185) 评论(0) 推荐(0)
LeetCode: Spiral Matrix
摘要: 多数次过。很奇怪dfs函数声明的时候形参里dir[][]不能用,必须为dir[4][2]. 1 class Solution { 2 public: 3 bool out(int x, int y, int m, int n) { 4 if (x >= m || x = n ... 阅读全文
posted @ 2013-04-21 09:19 ying_vincent 阅读(192) 评论(0) 推荐(0)
LeetCode: Sort Colors
摘要: 没写出来,看到网上一个非常好的code,不过这个code不太容易想出来 1 class Solution { 2 public: 3 void sortColors(int A[], int n) { 4 // Start typing your C/C++ solution... 阅读全文
posted @ 2013-04-21 06:21 ying_vincent 阅读(129) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 27 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3