• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 27 下一页
2013年4月23日
LeetCode: ZigZag Conversion
摘要: 没考虑到nRows == 1的情况,少数次过 1 class Solution { 2 public: 3 string convert(string s, int nRows) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文
posted @ 2013-04-23 04:07 ying_vincent 阅读(169) 评论(0) 推荐(0)
LeetCode: Word Search
摘要: 自己的思路对的,一直过不了large是因为把visit的建立放在循环最里层,导致每次都建一个两维vector耗了大量的时间。太傻逼了。。 1 class Solution { 2 public: 3 bool dfs(string word, int dep, int maxdep, vec... 阅读全文
posted @ 2013-04-23 03:40 ying_vincent 阅读(566) 评论(0) 推荐(0)
LeetCode: Word Ladder
摘要: 直接看答案。。 1 class Solution { 2 public: 3 int ladderLength(string start, string end, unordered_set<string> &dict) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 if (start.size() != end.size() || !dict.size()) return 0; 7 int dis... 阅读全文
posted @ 2013-04-23 02:29 ying_vincent 阅读(199) 评论(0) 推荐(0)
LeetCode: Wildcard Matching
摘要: 这题第一次做用dfs,结果过不了large,网上寻找到答案,这里s和p指针是会变的,重点处理ptr遇到*的时候,这个时候s和p都往后挪,p重新定位,看s后面和p后面的是不是match,如果不match则s向后移,再继续看后面的是不是match,直到s到底为止,这里str和ptr是浮动指针,s和p相对静止,记录前一个邵点。 1 class Solution { 2 public: 3 bool isMatch(const char *s, const char *p) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文
posted @ 2013-04-23 01:58 ying_vincent 阅读(285) 评论(0) 推荐(0)
2013年4月22日
LeetCode: Validate Binary Search Tree
摘要: 看了别人的代码 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * Tre... 阅读全文
posted @ 2013-04-22 15:00 ying_vincent 阅读(125) 评论(0) 推荐(0)
LeetCode: Valid Sudoku
摘要: 一次过。。 1 class Solution { 2 public: 3 bool isValidSudoku(vector > &board) { 4 // Start typing your C/C++ solution below 5 // DO NOT... 阅读全文
posted @ 2013-04-22 14:27 ying_vincent 阅读(228) 评论(0) 推荐(0)
LeetCode: Valid Parentheses
摘要: 一次过 1 class Solution { 2 public: 3 bool isValid(string s) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main... 阅读全文
posted @ 2013-04-22 13:59 ying_vincent 阅读(155) 评论(0) 推荐(0)
LeetCode: Valid Palindrome
摘要: 基本一次过吧,题目没说数字要算进去啊。。 1 class Solution { 2 public: 3 bool check(string t) { 4 for (int i = 0; i < t.size(); i++) { 5 if (t[i] != t[t.size()-1-i]) return false; 6 } 7 return true; 8 } 9 bool isPalindrome(string s) {10 // Start typing your C/C++ s... 阅读全文
posted @ 2013-04-22 13:43 ying_vincent 阅读(126) 评论(0) 推荐(0)
LeetCode: Valid Number
摘要: leetcode里最恶心的题目。。面试问这种题目可以去撞墙了。。自己写了一遍 1 class Solution { 2 public: 3 bool isNumber(const char *s) { 4 // Start typing your C/C++ solution... 阅读全文
posted @ 2013-04-22 13:29 ying_vincent 阅读(330) 评论(0) 推荐(0)
LeetCode: Unique Paths II
摘要: 一次过了 1 class Solution { 2 public: 3 int uniquePathsWithObstacles(vector > &obstacleGrid) { 4 // Start typing your C/C++ solution below 5 ... 阅读全文
posted @ 2013-04-22 12:19 ying_vincent 阅读(136) 评论(0) 推荐(0)
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 27 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3