• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
2013年4月10日
LeetCode: Next Permutation
摘要: 思路还是清楚的,从后面倒着数,中间有一些问题没考虑到,不过很快解决,少数次过 1 class Solution { 2 public: 3 void nextPermutation(vector &num) { 4 // Start typing your C/C++ sol... 阅读全文
posted @ 2013-04-10 13:02 ying_vincent 阅读(203) 评论(0) 推荐(0)
LeetCode: N-Queens II
摘要: 这道题其实我原来的思想是对的,不过不知道vector的速度要比数组慢很多,还有就是把参数放到private里也会减少运行时间。memset的时间和一个for循环是一样的,所以以后如果能确定一个数组的size并且不会改变数组大小的,就可以不用vector而用数组。多数次过 1 class Soluti... 阅读全文
posted @ 2013-04-10 12:11 ying_vincent 阅读(242) 评论(0) 推荐(0)
LeetCode: N-Queens
摘要: 很惊奇这题一次过了,不过我的code感觉比较冗长,建议看网上答案 1 class Solution { 2 public: 3 void dfs(vector &visit, vector &rec, vector> &ret, int dep, int n) { 4 if ... 阅读全文
posted @ 2013-04-10 09:17 ying_vincent 阅读(188) 评论(0) 推荐(0)
LeetCode: Multiply Strings
摘要: 一点小失误,少数次过 1 class Solution { 2 public: 3 string multiply(string num1, string num2) { 4 vector mul(num1.size() + num2.size()); 5 f... 阅读全文
posted @ 2013-04-10 07:13 ying_vincent 阅读(192) 评论(0) 推荐(0)
LeetCode: Minimum Window Substring
摘要: 自己写的large没过,用了map,然后用了很多erase, iterator的,懂得一个道理,map这玩意比较慢,尽量少用,在用网上答案的时候没有给数组初始化为0就过不了 1 class Solution { 2 public: 3 string minWindow(string S, s... 阅读全文
posted @ 2013-04-10 02:05 ying_vincent 阅读(204) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3