摘要: typedef struct tagCharUsed { int i; int j; bool used; tagCharUsed(int _i, int _j, bool _used = false): i(_i), j(_j), used(_used){};} CharU... 阅读全文
posted @ 2014-03-20 15:23 卖程序的小歪 阅读(206) 评论(0) 推荐(0) 编辑
摘要: Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文
posted @ 2014-03-19 23:57 卖程序的小歪 阅读(167) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(... 阅读全文
posted @ 2014-03-19 01:23 卖程序的小歪 阅读(152) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int minDepth(TreeNode *root) { if (root == NULL) return 0; int min_depth = INT_MAX; dfs(root, 0, min_d... 阅读全文
posted @ 2014-03-18 16:15 卖程序的小歪 阅读(174) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int minDistance(string word1, string word2) { const int cols = word1.length() + 1; const int rows = word2.len... 阅读全文
posted @ 2014-03-18 15:36 卖程序的小歪 阅读(240) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: vector > combinationSum2(vector &num, int target) { sort(num.begin(), num.end()); vector > tmp; vector sel; dfs(num, 0, target, sel, tmp); return tmp; } void dfs(vector &num, int pos, int target, vector& sel, vector >& r... 阅读全文
posted @ 2014-03-17 21:10 卖程序的小歪 阅读(176) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: vector > combinationSum(vector &candidates, int target) { sort(candidates.begin(), candidates.end()); candidates.erase(unique(candidates.begin(), candidates.end()), candidates.end()); vector > tmp; vector sel; dfs(... 阅读全文
posted @ 2014-03-17 19:54 卖程序的小歪 阅读(193) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int lengthOfLongestSubstring(string s) { int len = s.length(); if (len mlen) mlen = clen; q++; ... 阅读全文
posted @ 2014-03-15 12:41 卖程序的小歪 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne... 阅读全文
posted @ 2014-03-15 10:35 卖程序的小歪 阅读(171) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNode(int x) : label(x), next(NULL), random(NULL) {} * }; */class Solution {public: RandomListNode *copyRandomList(RandomListNode *head) { ... 阅读全文
posted @ 2014-03-14 21:10 卖程序的小歪 阅读(328) 评论(0) 推荐(0) 编辑